JSON Validator

Check JSON and see exactly where and why it breaks.

Runs locallyYour input is processed in this tab. The editor blocks outgoing network requests.
JSON input

The JSON Validator checks whether text is valid JSON and, when it is not, tells you the line, the column and the most likely cause, with a one-click fix for common mistakes. Use it to lint a config file or confirm an API payload before you ship it. Validation runs in your browser; nothing is uploaded.

How to validate JSON

  1. Paste the JSON, drop a .json file, or press ⌘/Ctrl O. The check runs as soon as the text changes.
  2. Read the result: a green "Valid JSON — no syntax errors found" with key count and depth, or an error panel naming the line, column and likely cause. Press F8 to move the cursor to the error.
  3. For trailing commas, single quotes and unquoted keys, use Fix trailing commas & quotes automatically. Once the JSON is valid, send it to the JSON Formatter or convert it to YAML.

Examples

Trailing comma in a package file

A comma left behind after the last array item, one of the most frequent reasons JSON fails to parse.

JSON
{
  "name": "formattr",
  "version": "1.0.0",
  "keywords": ["json", "format",],
}

Result:

Text
Unexpected `]` at line 4, column 33.
Likely cause: trailing comma after the last item on line 4.

JavaScript object pasted as JSON

Unquoted keys and single-quoted strings, copied from source code or a browser console.

Text
{name: 'formattr', tags: ['json', 'sql'], active: true}

Result:

Text
Unexpected `name` at line 1, column 2.
This looks like a JavaScript object, not JSON. Keys must be double-quoted.

Missing comma after editing

Two properties with no comma between them, which usually happens when lines are moved or deleted by hand.

JSON
{
  "id": 7
  "name": "Ben"
}

Result:

Text
Unexpected `"` at line 3, column 3.
Likely cause: missing comma between items (after line 2).

Options explained

  • Indent — the indentation used when the validated JSON is shown in the output pane: 2 spaces, 4 spaces or a tab.
  • Allow comments & trailing commas — validates JSONC/JSON5-style input by ignoring // and /* */ comments and trailing commas, and reports how many were found.

Errors the validator explains

Most error messages have the shape "Unexpected token at line L, column C", followed by a hint; a few problems, such as a raw line break inside a string or a number with a leading zero, get a message of their own. These are the ones you will see most often and what to do about each.

Likely cause: trailing comma

A comma directly before ] or }. JSON allows commas only between items. Remove it, or use the automatic fix, which removes every trailing comma at once.

JSON strings must use double quotes

A single-quoted string such as 'admin'. Replace the quotes with ". If keys are unquoted too, the hint changes to "This looks like a JavaScript object", and the automatic fix handles both.

Object keys must be double-quoted

A bare key such as name:. Wrap it in double quotes: "name":.

Smart (curly) quotes found

Quotes that a word processor or chat app has turned into “ and ”. Retype them as straight quotes, or use the automatic fix.

JSON does not allow comments

A // or /* comment. Delete it, or turn on Allow comments & trailing commas if the file is meant to be JSONC.

JSON literals are lowercase / NaN is not valid in JSON

True, False and None come from Python; NaN, Infinity and undefined come from JavaScript. Use true, false, null or a number.

A string is not closed / Unescaped line break inside a string

"A string is not closed" means a closing quote is missing. When the string does close but contains a real line break, the message is "Unescaped line break inside a string" instead: line breaks and tabs inside strings must be written as \n and \t, and the automatic fix escapes them.

Input ends before the object closes — was it cut off?

Brackets are still open at the end of the input. Copy the value again from its source; terminals and log viewers often truncate long lines.

FAQ

Is it safe to validate production data here?

Yes. The validator runs in your browser inside an isolated frame that blocks network requests, so the JSON is never sent anywhere or stored on a server. Settings such as indent are remembered on this device, but the input is only kept if you choose "Remember my last input". That makes it suitable for payloads containing tokens or customer data.

What does "Unexpected token" mean in JSON?

The parser reached a character it did not expect at that position. The token itself is often not the mistake — a ] flagged as unexpected usually means the comma before it should not be there. That is why each error here comes with a likely cause that looks at the surrounding text, not only the character reported.

Does the validator check my JSON against a schema?

No. It checks syntax: whether the text is well-formed JSON that any standard parser will accept. It does not check required fields, value types or formats defined in a JSON Schema. A syntactically valid document can still be rejected by an API that expects a different structure.

Why does the validator only show one error?

JSON parsers stop at the first syntax error, because everything after it is ambiguous. Fix the reported problem and the check runs again immediately, showing the next error if there is one. The automatic fix handles several kinds at once — trailing commas, single quotes, unquoted keys, smart quotes and comments.

What does the automatic fix change?

It removes trailing commas and comments, converts single and curly quotes to double quotes, quotes bare keys, lowercases Python-style literals and replaces NaN or undefined with null. It rewrites your input rather than reformatting it, and lists what it changed. If the JSON is still invalid afterwards, the remaining error is shown.

Are duplicate keys an error?

No, but they are reported. The JSON specification only says keys should be unique, so the input still validates, and a notice names the key and its line: "Duplicate key: "x" (line 2). Most parsers keep only the last value." Remove or rename one of the two so every consumer reads the same data.

How is this different from the JSON Formatter?

Both use the same strict parser and error hints. The validator is for answering "is this valid, and if not, why", and offers the automatic fix. The JSON Formatter focuses on output: indentation, sorted keys, escaped Unicode and minified copies.

Syntax check vs lint

JSON has a small grammar, so linting JSON mostly means catching the habits of other languages: comments, single quotes, trailing commas and bare keys from JavaScript, or True and None from Python. The guide to common JSON errors walks through each with examples. For configuration written in YAML, the YAML Formatter validates with the same line-and-column reporting.

Browse all Data Formatters & Converters

Guides