Remove Invisible Characters From JSON

0 characters
Options

Aggressive mode rewrites emoji and right-to-left runs. For JSON payloads you usually want it off unless the text is prose.

Where they are

Every hidden character is marked in place, so you can see which key or string it was hiding in.

Nothing scanned yet.

U+200B always invisible — removed in default mode   U+200D invisible only in aggressive mode

Why invisible characters break JSON

Three failures come up over and over:

A byte order mark at the very start

A file saved as UTF-8 with BOM starts with U+FEFF. JSON.parse does not skip it, so the first thing it sees is not { or [ and it throws Unexpected token on line 1. The character is invisible, so the file looks like it starts with a bracket. It does not.

Zero width characters inside keys and values

A key that renders as name but contains U+200B is not the key name. The JSON parses fine, which is worse than an error: lookups silently miss, comparisons fail, and the two strings look identical in every log you print.

Tag characters and private use marks

Text copied out of a chat window or a web page can carry U+E0020U+E007F tag characters or private use codepoints. They are valid in a JSON string, so nothing complains, and they travel with the data into whatever consumes it.

How to find them in your editor

In VS Code, open the file, press Ctrl+F, turn on the regular expression button and search for:

[\u200B\u200C\u200D\u00AD\u2060\uFEFF\u034F]

Every hit is a character that should almost certainly not be there. In Vim or Neovim the same pattern works with /. On the command line, grep -P '[\x{200B}\x{200C}\x{200D}\x{00AD}\x{2060}\x{FEFF}]' finds them in a file.

What this page does and does not do

It removes invisible characters and then runs JSON.parse on the result, so you find out whether the cleanup was enough. That is the whole job.

It does not pretty-print, minify, sort keys or repair syntax. A missing comma is still a missing comma. If the panel says the JSON is invalid after cleaning, the remaining problem is real JSON syntax, not a hidden character.

Two characters worth knowing about

U+2028 LINE SEPARATOR and U+2029 PARAGRAPH SEPARATOR are legal inside a JSON string but were illegal in JavaScript source before ES2019, so they break the common pattern of dropping JSON straight into a <script> tag. They also look like ordinary line breaks. This page leaves both alone, because in a JSON string they may be exactly what was intended.

Is anything uploaded?

No. There is no backend. The cleanup and the validation both run in this browser tab, and your JSON never leaves your device.