XEVMS

How to find and fix a JSON syntax error

Use a small broken example to separate syntax errors from errors in the data your application expects.

Strip the example down to one object

Try pasting {"items":[{"name":"pen","quantity":2,}]} into the JSON formatter. This fails because the last property in the inner object is followed by a comma. Remove that comma to get {"items":[{"name":"pen","quantity":2}]}. The formatter can now indent the object and make its nesting easier to read.

If a larger payload still fails, check the matching braces and brackets around where the edited value sits. Look for single quotes around property names, pasted comments and literal line breaks inside strings. Fix one issue at a time so you can see which change made the payload parse.

Check the shape after the syntax passes

The string {"quantity":"2"} is valid JSON, but an application expecting a number may reject it. Compare the formatted result with the receiving application’s examples or schema. Check types, required fields and whether a list or an object belongs at the top level.

If your system wraps JSON in Base64, decode it before checking the syntax. Base64 changes how bytes are represented. It does not make a payload confidential, so use a small example with any personal data or credentials removed when sharing a bug report.

JSON specification (RFC 8259)

Tools