JSON GUIDE · 4 MIN READ

Fix common JSON errors

Diagnose invalid quotes, trailing commas, escapes, incomplete responses, and precision problems.

Read the location in context

An error location is where a parser could no longer continue, which may be after the original mistake. If a closing brace is highlighted, inspect the preceding field for a missing comma, colon, or closing quote. If parsing stops at the beginning, check whether you pasted HTML, a log prefix, or an empty response.

Strict JSON needs double-quoted names and strings, has no comments, and has no trailing commas. Actual newlines inside strings must be escaped as \n. A Windows-style path needs escaped backslashes when represented as JSON text.

{"path":"C:\\data\\file.json","message":"line one\nline two"}

Some problems survive syntax validation

A response with a status of 200 can still contain the wrong fields. Validate against a schema after syntax checking. Similarly, duplicate member names and very large numeric identifiers can parse while producing a value different from what the sender intended.

Keep the original text when debugging. Do not repeatedly replace quotes or remove backslashes across the entire document: that can alter valid string content. Fix the producing system when possible and use a small failing example to verify the repair.

Put it into practice

Further reading

← All JSON guides