textscrubr
Home / Blog / Hidden characters

Why Invisible Characters Break Your JSON (and How to Clean It)

Hidden characters2 min readUpdated 2026-06-24
Invisible characters break JSON because parsers expect exact syntax. A byte-order mark before the opening brace, or a zero-width space inside a key or value, is not valid where the parser expects it, so parsing fails. To fix it, strip invisible characters with a cleaner or save the file as UTF-8 without BOM.

JSON that looks perfect but will not parse is often carrying an invisible character. Here is why, and how to find and remove it.

Why JSON is so sensitive

JSON has strict syntax. The parser expects specific characters in specific places: an opening brace, quoted keys, colons, commas. An invisible character violates that structure without showing anything on screen:

Because you cannot see any of these, the error message rarely points you to the real cause.

How to find the culprit

How to fix it

Save as UTF-8 without BOM. In VS Code, click the encoding in the status bar and choose "Save with Encoding" > "UTF-8" (not "with BOM"). Most editors have the same option.

Strip the characters directly. If you are working with copied JSON, paste it into a cleaner that removes invisible characters. textscrubr strips the BOM, zero-width spaces, and other invisibles while leaving your JSON structure and spacing intact, so the parser gets clean input.

Prevent it in a pipeline

If JSON is generated or passed between tools, add a strip-BOM and strip-invisibles step so no hidden character ever reaches the parser. It turns a baffling, hard-to-reproduce bug into a solved problem.

Scrub this text in one click

textscrubr strips the hidden characters, em dashes, and double spaces, and keeps your lists, headings, and code exactly where you put them. Free, and it runs entirely in your browser.

Clean my text free →

Frequently asked questions

Why does my valid-looking JSON fail to parse?

Usually an invisible character: a byte-order mark before the opening brace, or a zero-width space inside a key or value. The parser sees invalid syntax even though nothing looks wrong on screen.

How do I find the invisible character breaking my JSON?

Check for a BOM in your editor's encoding indicator, search for code points like \uFEFF and \u200B with regex, or paste the JSON into a cleaner that reports hidden characters.

How do I remove a BOM from a JSON file?

Save the file as UTF-8 without BOM in your editor, or paste the content into a cleaner that strips the U+FEFF character along with other invisible characters.