🧰Daily Toolbox
← All guides
json

Why Your JSON is Breaking: The 3 Characters Chrome Won't Show You

2026-09-02 · 6 min read

You paste JSON into Chrome DevTools. It looks perfect. You hit parse. It explodes.

You check the validator. "Valid JSON." You check the linter. Green checkmark. You copy-paste it into three different tools. All say it's fine.

Then you waste two hours because of a character you can't see.

The usual suspect: trailing commas

Everyone knows trailing commas break JSON. Most tools catch them. This isn't about that.

This is about the invisible ones.

Character 1: Zero-width space (U+200B)

You copy JSON from Slack. Someone pasted it there from a Google Doc. Somewhere in that chain, a zero-width space hitched a ride.

What it looks like: Nothing. Literally invisible. Not whitespace. Not a newline. Just... there.

Where it hides: Between quotes. After colons. Inside string values.

How to find it:
```javascript
// This will be true if you have one
yourString.includes('\u200B')
```

Or paste your JSON into the text diff tool and compare against a clean copy. The diff will show a phantom character.

Character 2: Non-breaking space (U+00A0)

Looks like a space. Acts like a space. JSON parsers hate it.

Where it comes from: Copy-pasting from Word, Notion, or rich text editors. They love inserting these instead of normal spaces (U+0020).

The symptom: `JSON.parse()` says "Unexpected token" but points to whitespace that looks totally normal.

How to find it:
```javascript
// Replace all non-breaking spaces with regular ones
cleanJson = dirtyJson.replace(/\u00A0/g, ' ')
```

Or use the JSON Formatter tool — it normalizes all spaces before parsing.

Character 3: Byte Order Mark (U+FEFF)

This one is brutal because it only appears at the very start of the file, so you never see it.

Where it comes from: Windows Notepad saving as "UTF-8 with BOM." Excel exporting JSON. Copying from certain terminal outputs.

The symptom: First character in your JSON is `` (if you view as Latin-1) or nothing (if your editor hides it). Parse fails with "Unexpected token" on line 1.

How to find it:
```bash
# In the terminal
xxd yourfile.json | head -1
# If you see ef bb bf at the start, you have a BOM
```

Or paste into the Base64 encoder — the first few characters will decode to `\uFEFF`.

How to remove it:
```javascript
cleanJson = dirtyJson.replace(/^\uFEFF/, '')
```

The nuclear option: strip everything invisible

If you just want to fix it and move on:

```javascript
function sanitizeJSON(str) {
return str
.replace(/^\uFEFF/, '') // BOM
.replace(/\u200B/g, '') // zero-width spaces
.replace(/\u00A0/g, ' ') // non-breaking spaces
.replace(/[\u200E\u200F]/g, '') // left-to-right / right-to-left marks
}
```

Paste your broken JSON into the Text Replacer tool, run this regex: `[\u200B\u00A0\uFEFF\u200E\u200F]`, replace with nothing. Then try parsing again.

Why validators don't catch this

Most online validators parse the JSON as a string first, which automatically strips or ignores these characters. So the validator sees clean JSON, but your code doesn't.

Chrome DevTools has the same problem. It renders the invisible characters as... nothing. So you're debugging JSON that looks perfect but isn't.

How to prevent it

1. Always copy-paste through a plain text editor first (Notepad++, VS Code, Sublime). Rich text editors inject garbage.

2. If you're receiving JSON from an API, check the Content-Type header. If it says `charset=UTF-8` but includes a BOM, file a bug.

3. Use a linter that specifically checks for invisible Unicode (`eslint-plugin-unicorn` has a rule for this).

4. When in doubt, run your JSON through the sanitizer above before parsing.

Real-world example

I once spent three hours debugging a production issue where user analytics weren't saving. The JSON payload looked perfect in the network tab. The API was returning 200. No errors logged.

Turns out a product manager had copy-pasted event names from a Confluence doc. Every single event name had a zero-width space at the end. The database was saving them, but queries were failing because `"signup"` != `"signup\u200B"`.

The fix was three lines of code. The diagnosis took three hours.

Try it now

Open Daily Toolbox → JSON Formatter. Paste your broken JSON. Click Format. If it works, you had a visible syntax error. If it still fails, click the "Clean invisible characters" checkbox and try again. That's the sanitizer running under the hood.

#json#debug#unicode

Try the free tools mentioned above

Open dev tools →