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

SyntaxError: Unterminated string in JSON

The parser opened a string with a double quote and never found the matching closing quote before the data ended. Position N points at where the runaway string began — look there for a missing quote, an unescaped newline, or a raw tab inside the value.

What the error means

A JSON string must open and close with " on the same logical line, with any special characters escaped. "Unterminated string" means the parser read past where the string should have closed and ran out of input.

The three causes

1. Missing closing quote. Count your quotes near position N — an odd number means one is missing.
2. Raw newline inside a string. A literal line break inside the quotes is illegal; it must be written as \n.
3. Raw tab or control char. Same rule — tabs become \t, etc.

Fix it

Jump to position N in your editor (most show line/column). Escape any embedded newlines and tabs, and add the missing closing quote. Paste the payload into the tool above and hit Repair — it re-escapes control characters and closes obvious dangling strings so you can see the corrected shape.

FAQ

What does position N point to?

It is the character offset where the unterminated string starts, not where it should have ended — so scan forward from N for the missing quote.

My JSON came from a multi-line template literal — why does it fail?

Template literals keep real newlines. Serialize with JSON.stringify() instead of building JSON by hand, and newlines get escaped automatically.

Can a stray backslash cause this?

Yes — a trailing backslash like "path\" escapes the closing quote, so the string never terminates. Use \\ for a literal backslash.