Skip to content

JSON Troubleshooting

How to Fix Common JSON Errors

A parser points to where it got stuck. These examples show how to find the syntax mistake, repair it, and check the result.

Last updated: October 24, 2026

JSON parsing errors usually come from one character: a quote, comma, colon, or closing delimiter. Start with the parser location, inspect the surrounding structure, then validate the corrected document. For common formatting mistakes, MyJSONPal Fix JSON can suggest repairs in your browser; review its change list because the repair is heuristic.

JSON is not a JavaScript object literal

JSON is a text data format with stricter syntax than JavaScript. Object keys and string values must use double quotes. JSON has no comments, trailing commas, undefined,NaN, or executable expressions. This JavaScript-like value is not valid JSON:

{ name: 'Ada', active: true, }

The JSON equivalent is:

{ "name": "Ada", "active": true }

A JavaScript runtime may accept an object literal that JSON.parse() rejects. If a value needs to be JSON, validate it as JSON rather than assuming that JavaScript syntax is interchangeable.

Use double quotes around strings and keys

Single-quoted strings and bare keys are common when copying JavaScript or Python-like data.

{ 'name': 'Ada' }  // invalid JSON
{ "name": "Ada" }  // valid JSON

JSON strings also need escaping for quotes, backslashes, and control characters. For example, write an embedded quote as \" inside the JSON string. Fix JSON can convert common single-quoted strings and quote unquoted keys; always check that the intended text survived.

Check commas between members, not after the last one

A comma separates array items or object members. It is not allowed after the final item.

{ "name": "Ada", "active": true, }  // trailing comma
{ "name": "Ada", "active": true }

A missing comma is the reverse problem:

["red" "blue"]  // invalid
["red", "blue"]  // valid

The repair tool removes trailing commas and attempts to insert missing commas. It reports the changes so you can verify that no separator was added in the wrong place.

Put a colon between each key and value

Every object member has the form "key": value. A comma is not a substitute for a colon.

{ "name", "Ada" }  // missing colon
{ "name": "Ada" }

Auto-Fix does not infer a missing colon. Add it manually, then check that the value belongs to the intended key.

Match every brace and bracket

Objects open with { and close with }; arrays open with[ and close with ]. They must also close in the correct order.

{ "items": [1, 2 }  // array closes with the wrong delimiter
{ "items": [1, 2] }

A parser cannot know where a missing closing delimiter belongs, so Auto-Fix does not guess missing braces or brackets. Count nested pairs from the inside out; an unexpected end of input often means a closing delimiter or quote was never supplied.

Use only JSON values

JSON values are strings, numbers, objects, arrays, true, false, andnull. Booleans and null are lowercase. undefined, NaN,Infinity, and bare words such as active are not JSON values.

{ "active": True, "label": ready, "score": NaN }  // invalid JSON
{ "active": true, "label": "ready", "score": null }  // valid JSON

Fix JSON converts common Python-style booleans and null-like literals, and quotes bareword values. Its current handling maps NaN and Infinity tonull; that changes the value, so compare the result with your intended data.

Read line and column numbers as clues

A parser reports the point where it could no longer continue, which may be just after the real mistake. Check that character and a few characters before it. A message such as “unexpected token” can indicate an unexpected quote, comma, bracket, or value; the token itself is not always the root cause.

  • Line counts newline-separated lines, usually starting at 1.
  • Column identifies a position within that line; editors may count from 1 while some runtime messages use a zero-based offset.
  • Unexpected end means the input ended while the parser still expected a value, quote, brace, or bracket.

Check nearby commas and delimiters first, and be aware that tabs, Unicode characters, and different parser implementations can make reported positions look slightly different. MyJSONPal shows line and column locations for parse errors. After editing, use theJSON formatter and validator to confirm the text parses, or return toFix JSON to review supported automatic repairs.