On this page

To fix a JSON syntax error, validate the text, check the reported position and the character before it, make one small correction, and validate again. The highlighted location may be where the parser stopped understanding the document; the cause can be on the previous line.

  1. Paste the complete document into the JSON validator and select Validate JSON.
  2. If the diagnostic includes a line and column, inspect that area and the end of the previous line.
  3. Fix one issue at a time: a missing comma, an extra comma, a quote, or a closing bracket.
  4. Validate the complete document again after each change.

Keep a copy of the original so you can review your edits. The validator reports problems; you choose the correction.

How to read an error location

A missing comma may only become apparent when the parser reaches the next key. A missing closing bracket may be detected at the end of the text. Read around the reported position before deleting the highlighted character.

The message and location depend on the program parsing the JSON. MDN lists examples of parsing diagnostics; other parsers can use different wording.

If there is no location, read from the beginning and check where each value ends and the next one starts. For a large file, revisit the area you just edited first. Adding indentation manually can make the structure easier to follow, but indentation alone does not fix the error.

Example: the error points to a key, but a comma is missing before it

This document is invalid:

{
  "order": {
    "id": "A-17"
    "total": 42
  }
}

The parser may point to "total" or a nearby position. The key is written correctly: the comma separating it from the previous field is missing. Add it after "A-17":

{
  "order": {
    "id": "A-17",
    "total": 42
  }
}

Paste this second version and select Validate JSON again. The expected result is Valid JSON. The identifier and total are unchanged; only the missing separator has been added.

Four errors you can fix with a small edit

The inputs in the second column are deliberately invalid. The last column contains valid JSON documents:

Problem Invalid input Smallest correction Valid result
Missing comma between fields {"id":"A-17" "total":42} Add a comma after the identifier. {"id":"A-17","total":42}
Extra comma at the end of an array {"tags":["one","two",]} Remove the comma after "two". {"tags":["one","two"]}
Single quotes around a key {'active':true} Replace the key’s quotes with double quotes. {"active":true}
Unclosed object {"active":true Add } at the end. {"active":true}

Commas separate object fields or array elements; keys and text values use double quotes. These rules are part of the JSON syntax defined by ECMA-404.

When the document contains comments

Strict JSON does not allow comments. If the original is a JSONC configuration, see how JSON and JSONC differ and how to convert it. That conversion removes comments and trailing commas; keep the original if its annotations are needed to maintain the configuration.

When the problem is inside a string

In {"note":"She said "hello""}, the quotes around "hello" end the string too early. Escape them to keep those quotes in the text:

{"note":"She said \"hello\""}

Avoid replacing every quote automatically: some characters may belong to the value itself.

When the document ends unexpectedly

The last table example needs only a closing brace. If your input stops halfway through a string or record, first check whether you copied or received the complete document. Adding closing brackets can produce valid syntax without recovering missing data.

For an AI response, follow the review of AI-generated JSON to compare proposed changes and decide when to request the complete data again.

Check the fix and preserve the intended data

Validate the entire document again, even if you changed only one line. If another error appears, repeat the process. Once validation succeeds, choose whether to format or minify it and review the values before saving.

Also check what the application expects. {"total":"42"} and {"total":42} are both valid JSON, but the first contains text and the second a number. Syntax validation does not apply a JSON Schema or check business requirements.

If the tool reports a size limit, cancellation, or file reading failure, address that message before changing punctuation: it does not establish a syntax error. For background on objects, arrays, and types, see the guide to what JSON is.

Share this guide

Article link