Fixing "Unterminated String in JSON" Parsing Errors
An "unterminated string in JSON" error means the parser started reading a string value (right after an opening double quote) and reached the end of the input, or hit an unescaped newline, before ever finding the matching closing quote to end that string. Unlike some JSON errors, this one usually points to a fairly specific, findable location in the source text.
The most common cause is an unescaped double quote inside the string's actual content. If a string value contains a raw " character that wasn't escaped as \", the parser interprets that quote as the end of the string — and then everything that follows is parsed as if it were outside the string, which almost always produces a confusing cascade of further errors once the parser starts trying to interpret content that was meant to still be inside the string as JSON structure instead.
Unescaped newlines inside a string cause the same failure. JSON strings cannot contain a literal line break — a newline inside a string value must be represented as the two-character escape sequence \n. This trips people up constantly when JSON is generated by concatenating multi-line text (like a paragraph of user-written content) into a string without properly escaping it first.
This error is also extremely common when JSON is hand-edited or partially copy-pasted, and a closing quote gets accidentally deleted, or when JSON is truncated mid-string — the same underlying truncation issue that causes 'unexpected end of JSON input' in other cases, just manifesting specifically inside a string value rather than at the structural level.
To actually locate the problem, most JSON parsers report a line and column number alongside the error — start there, but be aware the reported position is often a little after the actual mistake, since the parser doesn't realize something's wrong until it's already consumed extra characters trying (and failing) to find the closing quote.
The fastest fix in practice is to paste the problematic JSON into a tool that highlights the exact error location visually rather than just giving you a line number to count to manually — our JSON Validator shows precisely where parsing failed, which is significantly faster than scanning a long JSON blob by eye, especially when the string in question spans multiple lines or contains a lot of content.
Going forward, if you're generating JSON by manually building strings (rather than using JSON.stringify() or an equivalent serializer, which handles all of this escaping automatically and correctly), that's really the root cause worth fixing — manual string concatenation into JSON is exactly how unescaped quotes and newlines end up in the output in the first place, and switching to a proper serializer eliminates this entire category of error.
Found this helpful?
SyncTonight's tools and guides are free and always will be. If this post saved you some debugging time, a coffee goes a long way — no pressure, just appreciated.
☕ Buy me a coffee