Debug Invisible Characters in JSON Data

Find hidden whitespace characters in JSON strings that cause parse errors, key mismatches, and validation failures. Visualize and fix JSON whitespace issues.

Unicode Whitespace

Detailed Explanation

Hidden Characters in JSON

JSON is strict about its syntax, and invisible characters lurking in your JSON data can cause parsing failures, key mismatches, and data corruption. The Whitespace Visualizer helps you find these hidden problems.

Common JSON Whitespace Issues

1. BOM at the Start

The JSON specification (RFC 8259) states that JSON text should not begin with a BOM. However, files saved by Windows Notepad or Excel exports may include one:

[BOM]{"name": "John"}  // Many parsers reject this

2. NBSP in String Values

Non-breaking spaces in JSON values look correct but cause comparison failures:

{"city": "New York"}  // NBSP between "New" and "York"

When you compare this with "New York" (regular space), the comparison fails.

3. Zero-Width Characters in Keys

ZWS or ZWJ characters in JSON keys make two keys that look identical actually different:

{
  "user\u200Bname": "alice",  // contains ZWS
  "username": "bob"             // clean key
}

Both keys appear as "username" in any viewer, but they are distinct.

4. CRLF in Multi-line Strings

JSON strings should use \n for newlines. If CRLF appears in a value, the \r may be passed through or cause issues downstream:

{"message": "line1\r\nline2"}  // CRLF embedded in value

Debugging Process

  1. If your JSON fails to parse, paste it into the Whitespace Visualizer.
  2. Check for [BOM] at the start of the text.
  3. Look for ° (NBSP), [ZWS], or [ZWJ] markers within string values and keys.
  4. Check the Line Endings panel for unexpected CRLF.
  5. Use the Clean feature to strip the offending characters.
  6. Copy the cleaned JSON and verify it parses correctly.

For JSON formatting and validation, use the JSON Formatter after cleaning.

Use Case

An API returns a 400 error when sending JSON data that was constructed by concatenating strings from a database and user input. The Whitespace Visualizer reveals zero-width spaces in the user input and a BOM from the database export. Cleaning these characters makes the API request succeed.

Try It — Whitespace Visualizer

Open full tool