Skip to content
koducathome

JSON Validator

Validate JSON against the strict RFC 8259 grammar, locate errors by line and column, and detect duplicate keys.

How to use this tool

Steps for using the JSON Validator.

  1. Paste your JSON into the JSON to validate editor, or click Sample (valid) or Broken sample (contains an error).
  2. Leave Validate as I type on for instant feedback, or click Validate to check on demand. Live checking pauses for inputs over 200,000 characters.
  3. If the document is invalid, read the error: it gives the line, the column, a plain-English reason and an excerpt with a caret under the problem. The line number is also highlighted in the editor gutter.
  4. If the document is valid, review the duplicate keys list — each entry shows the repeated key, the path of the object that contains it and the line where the repeat appears.
  5. Check the Structure summary (root type, maximum depth, key count and counts per value type), then use Copy report to paste the result into a ticket or code review.

Example

Trailing comma inside an array

Invalid JSON
{
  "id": 7,
  "tags": ["a", "b",]
}
Error reported
Invalid JSON at line 3, column 21
Trailing comma is not allowed before ']'.

Common use cases

  • Finding why an API request body is rejected with a 400 Bad Request or "malformed JSON" error.
  • Checking hand-edited configuration files such as package.json, tsconfig.json or composer.json before committing.
  • Detecting duplicate keys introduced by a bad merge, which most parsers accept silently.
  • Confirming that a payload copied from logs or a chat message is complete and not truncated.
  • Getting a quick sense of a document's shape — depth, size and value types — before writing code to consume it.

What the JSON validator checks

The validator checks your text against the JSON grammar in RFC 8259 — the same rules JSON.parse in JavaScript, json.loads in Python and most API gateways enforce. Strings must use double quotes, property names must be quoted, numbers cannot have leading zeros or a trailing decimal point, and comments, trailing commas, undefined, NaN and Infinity are all rejected. A leading byte order mark is tolerated because many editors on Windows add one.

When the browser's parser rejects a document, a separate strict scanner re-reads it to find the exact character where it first stops being JSON. That is why the error includes a reliable line and column and a specific message such as "Property names must be wrapped in double quotes" rather than a generic "Unexpected token". Only the first error is reported: after a syntax error the rest of the document cannot be interpreted with certainty, so fix it and validate again.

Duplicate keys are legal according to the grammar, but RFC 8259 says object names "SHOULD be unique" and parsers disagree on what to do with repeats. JavaScript and Python keep the last value, some streaming parsers keep the first, and a few reject the document. A duplicate usually means a merge went wrong or a config value is being silently overridden, so the validator lists every one with the containing object's path, such as $.users[0].

The structure summary is computed from the parsed value. Maximum depth counts nested containers (a flat object is depth 1), and total keys counts object properties across the whole document. Because parsing keeps only the last value of a duplicated key, duplicates are not double-counted in these statistics.

Limitations

  • Checks syntax only. To check required fields, types and value ranges, use the JSON Schema Validator.
  • Reports the first syntax error only; later errors appear once the first is fixed.
  • JSON5, JSONC (JSON with comments) and newline-delimited JSON are not accepted. For JSON Lines files use the JSONL Validator.
  • Input is limited to 2 million characters.

Frequently asked questions

How is this different from the JSON Formatter?

The JSON Formatter is for reformatting: it pretty-prints or minifies and shows a tree view. The validator does not change your text; it focuses on diagnosis — duplicate keys with their paths and lines, and a structural summary of the document.

Are duplicate keys an error?

Not according to the JSON grammar, so the document is still reported as valid. They are shown as a warning because different parsers resolve them differently, which can lead to bugs that only appear in one language or service.

Why does my JSON with comments fail?

Standard JSON has no comment syntax. Files like VS Code's settings.json use JSONC, a superset that allows comments. Remove // and /* */ comments, or keep the file in a tool that understands JSONC.

Does validation happen on a server?

No. Parsing, duplicate detection and statistics all run in your browser; your JSON is never uploaded.

Why is the column number different from my editor's?

Columns are counted in characters starting at 1, and a tab counts as one character. Editors that display tabs as several spaces may show a larger column for the same position.