Fast check
If a request body, config file, package file, or log payload will not parse, paste the smallest failing snippet into the JSON Validator. Once it passes, use the JSON Formatter only for readability or minification.
A JSON parse error usually means the text is almost JSON, but one character or rule is wrong. Start by validating the same text that failed, then fix the earliest syntax problem before formatting it.
If a request body, config file, package file, or log payload will not parse, paste the smallest failing snippet into the JSON Validator. Once it passes, use the JSON Formatter only for readability or minification.
| Error pattern | Broken JSON | Fix |
|---|---|---|
| Trailing comma | {"name":"Sam",} | {"name":"Sam"} |
| Single quotes | {'name':'Sam'} | {"name":"Sam"} |
| Unquoted key | {name:"Sam"} | {"name":"Sam"} |
| Comment inside JSON | {"ok":true // note} | Remove the comment before parsing. |
| JavaScript-only value | {"count":undefined} | Use null, a number, string, boolean, array, or object. |
| Raw newline in a string | {"text":"line 1 [line break] line 2"} | Use an escaped newline: {"text":"line 1\nline 2"}. |
| Missing close brace | {"items":[1,2,3] | {"items":[1,2,3]} |
Parser messages often point to where parsing finally failed, not where the real mistake started. A missing quote or comma can make the next line look wrong. If the payload came from logs, also check for copied prefixes, truncated output, or extra text before and after the JSON.
Many parse errors happen because the text is valid JavaScript object syntax but not valid JSON. JSON requires double quotes around object keys and string values, does not allow comments, and does not allow values such as undefined, NaN, or Infinity. MDN documents the common JSON.parse SyntaxError patterns.
| Situation | Open |
|---|---|
| The payload throws a parse error or came from logs. | JSON Validator |
| The JSON already parses but is hard to read. | JSON Formatter |
| You are not sure whether to validate or format first. | JSON Formatter vs Validator |
| The payload includes tokens, customer data, or production details. | How to Format JSON Safely |
It means the parser could not turn the text into valid JSON. The cause is usually a syntax issue such as a trailing comma, single quotes, an unquoted key, a missing brace, or an invalid escape sequence.
Validate first when you see a parse error. Formatting is useful after the JSON parses cleanly; it will not reliably explain why broken JSON failed.
JSON is stricter than JavaScript object literals. JSON requires double-quoted object keys and string values, does not allow comments, and does not allow values like undefined, NaN, or Infinity.