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.
invalid byte sequence for encoding "UTF8" 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 not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
Most viewed in PostgreSQL
- could not connect PostgreSQL: could not connect to server / connection refused — Is the server running on host and accepting TCP/IP connections?
- pg_restore text dump pg_restore: error: input file appears to be a text format dump. Please use psql.
- 25P02 ERROR: current transaction is aborted, commands ignored until end of transaction block
Other ways to find it
Where this error sits
Origin: Data. Errors that are often confused with or caused by this one (click to open):
🧠 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.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 12 Oct 2026