ERROR: invalid byte sequence for encoding "UTF8": 0x00
Text contained bytes invalid in UTF-8 — often a NUL byte (0x00) or Latin-1/Windows-1252 data.
Seen on:
PostgreSQL
Meaning
PostgreSQL text can’t contain \0. Imports from Excel/CSV in Windows encodings or binary data in text columns fail.
Common causes
- NUL bytes in strings (from binary data or C strings)
- CSV in Windows-1252/Latin-1 imported as UTF-8
- Binary stored in text instead of bytea
⚡ Quick fix
- Strip \u0000 before inserting
- Convert files to UTF-8 (iconv)
- Use bytea for binary data
- COPY … WITH (ENCODING 'WIN1252')
Detailed fix by platform
Linux
iconv -f WINDOWS-1252 -t UTF-8 export.csv > export-utf8.csv
How to diagnose
- Byte — Which byte? 0x00 = NUL
- Source — File encoding?
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026