Developer tools

How to fix common JSON syntax errors

Find missing quotes, trailing commas, and unescaped characters using short examples and a JSON validator.

When a JSON parser rejects a file, check the smallest section around the error first. Typical repairs include double-quoting keys, removing a trailing comma, and escaping quotation marks inside a value.

Open the JSON Formatter

Large curly braces surround a set of data tiles.

Separate JSON from JavaScript syntax

An object written as {active: true} can be valid JavaScript, while JSON requires {"active": true}. JSON strings use double quotes, the literals true, false, and null are lowercase, and JavaScript-specific values such as undefined have no JSON equivalent.

Look for an extra comma at the end

The array ["photo.jpg", "receipt.png",] has an extra comma. Remove it to get ["photo.jpg", "receipt.png"]. Apply the same rule before a closing brace. When an editor points to a closing bracket, check the last item before it as well.

Check quoted text and paths

A literal quotation mark inside a string needs a backslash before it. A literal backslash also needs escaping. If you are constructing JSON from values in code, use the language’s JSON serializer instead of assembling strings by hand. That keeps paths, newlines, and punctuation intact.

Validate with a small, safe sample

If a large payload fails, copy just the affected object into a scratch file. Remove account identifiers and tokens from anything you plan to share. Validate the small example, then apply the same repair to the original and format it so nesting is easy to inspect.

References

Browse the Journal

Find a tool