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.

Runs entirely in your browser — your JSON is never uploaded to a server. No ads injected into the output, no sign-up, and the repair logic is tuned for this exact error rather than generic pretty-printing.

How to fix "Unterminated string in JSON at position N"

  1. Locate the open quote. Position N points at where the string began. A closing double-quote is missing, or a quote inside the string was not escaped and ended it early.
  2. Close or escape the quote. Add the missing " at the end of the value, or escape any interior quote as \". Paste the payload above and press Repair.
  3. Check for a cut-off payload. If the string runs to the very end of the input, the response was truncated mid-transfer — refetch the full body.

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.