Fix JSON control characters (no upload)

TL;DR: Make the JSON strict, validate locally, then export/convert (no upload).

How control characters break JSON.parse, where they come from, and how to clean input safely using no-upload tools.

Why control characters break JSON

JSON strings can’t contain unescaped control characters like newlines, tabs, or null bytes unless properly escaped.

When you paste text from logs or copy from terminals, invisible characters can sneak in and make parsing fail.

  • Common offenders: \n as a raw newline inside a string, \t, and \u0000.
  • The error often mentions an “invalid control character” or points near the suspicious string.

Where they come from

Log lines and stack traces are frequent sources because they include raw line breaks inside quoted values.

Clipboard conversions and encoding issues can also introduce unexpected bytes, especially when moving between tools.

Safe cleanup approach

If a value needs to preserve line breaks, replace raw newlines with \n within strings.

Validate locally after each small fix. It’s faster than doing a big global replace and guessing.

When the source is logs, the easiest fix is often to extract the JSON part only (without the log prefix/suffix), then validate again.

How to spot invisible characters

Control characters are often invisible in plain editors. If the validator points to a specific area, focus on the nearest string value and look for pasted line breaks or tabs inside quotes.

  • Raw newline in a string: convert it to \\n (two characters) inside the JSON string.
  • Tab character: convert it to \\t inside the string.
  • Null byte: remove it (it usually has no meaning in JSON payloads).

Trust note: All processing happens locally in your browser. Files are never uploaded.

FAQ

Should I delete control characters? Only if they are truly noise. If they represent formatting, escape them instead so the meaning stays intact.

Is it safe to use online cleaners? Avoid uploads for private data. Local validation keeps the payload on-device.

Local verification snippet

Run a quick local check before export/convert:

const text = input.trim();
const value = JSON.parse(text);
console.log(Array.isArray(value) ? 'array' : typeof value);
Privacy & Security
All processing happens locally in your browser. Files are never uploaded.