formatjson.pro
Validate, pretty-print or minify JSON in your browser — nothing is uploaded.

JSONDecodeError: Invalid control character at

Python's json module found a raw control character (newline, tab, or a byte below 0x20) inside a string value. JSON requires these to be escaped. Escape them (\n, \t, \r) at the source, or pass strict=False to json.loads() to tolerate them.

What the error means

By spec, JSON string literals cannot contain unescaped control characters (U+0000–U+001F). When json.loads() meets a raw newline or tab inside a string, it stops with "Invalid control character at: line X column Y".

Where it comes from

Typically the JSON was produced by string concatenation or read from a source with embedded line breaks / Windows \r\n endings, instead of being generated with json.dumps().

Fix it

Best: regenerate the data with json.dumps(obj), which escapes control characters correctly.
If you cannot change the source: pass json.loads(text, strict=False) to allow control characters in strings.
Manual patch: replace raw newlines with \n and tabs with \t before parsing. Paste the payload above and hit Repair to escape the offending characters.

FAQ

Is strict=False safe?

It is fine for trusted, slightly-malformed data. For untrusted input, prefer fixing the producer so the JSON is valid, since strict=False masks a real formatting bug.

JavaScript says 'Bad control character in string literal' — same issue?

Yes, identical cause in a different runtime. Escape the control character or serialise with JSON.stringify().

Which column does it report?

The column of the offending control character within its line — jump there and escape that exact byte.