41 chars · 4 lines
Two-way sync · Edit either side and the other updates automatically.
"message": "first line↵41 chars · 4 lines
Two-way sync · Edit either side and the other updates automatically.
"message": "first line↵JSON string control-character error
Pretty-printed JSON may place line breaks between properties, but an actual line break inside a quoted string is different. Control characters in string content must use their escaped representation. This tool is free to use. No account or payment is required.
Last updated
Diagnose the problem
Whitespace between JSON tokens can include newlines. The restriction applies only after the parser has entered a quoted string value or property name.
When generating JSON in code, prefer JSON.stringify or an equivalent serializer instead of manually concatenating strings. The serializer will escape embedded newline characters correctly.
Resolve the issue
Use the solving tool
Run the focused checker with the failing payload to locate the parser error and inspect the nearby source before changing data.
Open JSON Error CheckerThe invalid value contains a literal line break; the valid version stores the same break as \n.
{
"message": "first line
second line"
}{
"message": "first line\nsecond line"
}Common questions
Yes, between tokens. A literal newline is invalid only when it appears inside a quoted JSON string.
Represent each line break with the escaped newline sequence \n in raw JSON text, or let a JSON serializer escape the string for you.
A programming-language string can add another escaping layer. Inspect the runtime JSON text to determine what JSON.parse actually receives.
Debugging a specific JSON issue? Browse JSON troubleshooting.