Text and data

How to Find and Fix JSON Syntax Errors

Keep the original payload, then use JSON Formatter to reproduce the parse failure. A parser error identifies where parsing stopped, which can be after the character that caused the problem. Message wording and position information vary by runtime.

Three review steps: How to Find and Fix JSON Syntax Errors
Review the source, inspect the output and test the finished result.

Confirm the response is supposed to be JSON

If an API response begins with HTML, inspect its HTTP status, final URL and Content-Type before editing its body. A login page or gateway response must be fixed at the request or server boundary; deleting angle brackets does not turn it into the intended data.

For an actual JSON document, reproduce the failure on a copy. Record the engine message and use any position the tool provides as a starting point, not a guaranteed byte offset or independent encoding diagnosis.

Repair one syntax defect at a time

The first example below has a trailing comma. Remove that comma only after checking the intended object. Unquoted keys, single-quoted strings and comments are also outside standard JSON. Do not remove punctuation globally because it may belong inside a string.

A Windows path needs escaped backslashes inside a JSON string. After each repair, parse again and inspect the resulting value, rather than assuming a successful parse means the intended data survived.

Invalid: {"name":"Example",}
Valid:   {"name":"Example"}

JSON source: {"path":"C:\\Reports"}
Parsed path: C:\Reports

Check values after syntax succeeds

Compare the repaired source with the original and check the keys, records and types the consumer needs. Valid JSON can still violate a schema or business rule. Ordinary JavaScript parsing can round large numeric identifiers; preserve them as strings where the contract permits.

Test the corrected payload in the receiving application or its contract tests. Stop when syntax, required structure and representative values are correct; a formatter alone cannot verify access rights, account balances or another domain-specific fact.

References

Use the linked specifications and product documentation to check behavior in your own environment.

Continue troubleshooting

Related tools

Frequently asked questions

Is a parse position always a byte offset?

No. Position information and error wording depend on the runtime; treat them as clues rather than a universal byte contract.

Can removing a trailing comma fix every unexpected-token error?

No. Inspect the exact source; an HTML response, broken escape or another defect may be responsible.

Does valid JSON prove the data is correct?

No. Schema, precision and business rules require separate checks.

Need help with a tool or found a bug?

Report an issue directly to engineering. No accounts required — all client data remains private on your device.

Report an Issue →