{ }JSON Workbench

Fix common JSON errors

A JSON parser reads strict syntax. A response that looks almost right can still fail because of a single quote or comma. Fix the first reported error, then validate again: later errors may be consequences of the first.

1. Use double quotes

Invalid: {'name': 'Ada'}
Valid:   {"name": "Ada"}

Both property names and string values need double quotes. A JavaScript object literal can use different syntax, but a JSON document cannot.

2. Remove trailing commas

Invalid: {"items": [1, 2,]}
Valid:   {"items": [1, 2]}

A comma separates values. It cannot appear immediately before the closing bracket or brace.

3. Escape quotes and backslashes

{"message": "She said \"hello\"", "path": "C:\\temp"}

A quote inside a string needs a backslash. A literal backslash needs a second backslash. Raw line breaks inside a string are invalid; use the escape sequence \n.

4. Remove comments and unsupported values

JSON has no comments, undefined, NaN, Infinity, functions, or date type. Convert dates to strings and decide explicitly whether a missing value should be omitted or represented as null. Do not mechanically remove comment markers from a document: URLs and strings may contain the same characters.

5. Check the source response

If an API response starts with an HTML tag, you may have received an error page rather than JSON. Check the HTTP status and content type before editing the body.

Understanding error locations

Browser error messages vary. When a character position is available, the formatter reports a line and column and selects the nearby character. The location is where parsing failed, which may be just after the actual mistake.

Try your corrected JSON โ†’