JSON Validator

Catch syntax errors with exact line, column, and a caret pointer — plus plain-English fix hints and structural stats.

0 chars · 1 lines

Precise error location

The first invalid character is reported with its line, column, and a caret pointer so you can jump straight to the fix.

Smart lint hints

Detects trailing commas, single quotes, comments, unquoted keys, and undefined / NaN — the five most common JSON mistakes.

Structure insight

Counts objects, arrays, keys, depth, and duplicate keys that JSON.parse would silently overwrite.

Strict JSON, briefly

The JSON specification (ECMA-404, RFC 8259) is intentionally tiny — six value types, two collection types, and a handful of literal tokens. That minimalism is what makes JSON portable across every language, but it also means the parser is unforgiving: anything that is not explicitly allowed is rejected.

The five mistakes this validator looks for

  • Trailing commas — legal in JavaScript, illegal in JSON. Remove the comma after the last item in any object or array.
  • Single quotes — JSON strings must use double quotes. Replace 'value' with "value".
  • Unquoted keys — every property name is a double-quoted string. {name: "a"} is invalid; {"name": "a"} is correct.
  • Comments — neither // nor /* */ are part of JSON. Strip them before parsing or switch to JSON5 / JSONC for tooling that supports them.
  • Non-valuesundefined, NaN, and Infinity are not valid JSON. Use null or omit the property entirely.

Why duplicate keys matter

When the same key appears twice inside one object, every mainstream parser keeps only the last occurrence and discards the rest — without warning. That is fine when it is intentional, but it can hide real bugs in hand-written configuration files, merged API responses, and templated payloads. This validator scans the raw source and reports every duplicate it finds so you can decide whether to deduplicate the data or change the schema.

Frequently asked questions

What does a JSON validator actually check?

A JSON validator parses your input against the strict JSON grammar defined in ECMA-404 and RFC 8259. It confirms that braces and brackets are balanced, every key is a double-quoted string, every string is properly terminated, every number is well-formed, and the top-level value is a valid JSON value. If parsing succeeds, the document is guaranteed to be loadable by any compliant JSON parser in any language.

How is this different from a JSON formatter?

A formatter focuses on rewriting valid JSON (beautify, minify, sort). A validator focuses on diagnosis: it pinpoints the exact line and column of the first error, shows a caret pointing at the offending character, lists likely causes (trailing comma, single quotes, comments, unquoted key), and reports structural stats like depth, key count, and duplicate keys. Use the validator when something is broken; use the formatter when it already parses.

Why is my JSON failing with 'Unexpected token'?

The browser's parser reports the first character it cannot legally accept. The five most common causes are: a trailing comma after the last item in an object or array, a single quote where a double quote is required, an unquoted property name, a missing closing brace or bracket, and a stray character (BOM, smart quote, non-breaking space) pasted in from a word processor. The validator highlights the line and column so you can jump straight to it.

Does the validator detect duplicate keys?

Yes. JSON.parse silently keeps only the last value when a key is repeated inside the same object, which can hide bugs. This tool scans the raw source and reports every duplicate key it finds — useful when you suspect an API or a configuration file is dropping values unexpectedly.

Is JSON5 or JSONC (JSON with comments) accepted?

No. This validator follows strict JSON, so it rejects // and /* */ comments, trailing commas, single-quoted strings, and unquoted keys. If you are working with JSON5 or JSONC, the validator will flag exactly which non-standard features are present so you can strip them before passing the payload to a strict parser.

Is my JSON sent to a server?

No. All parsing, error detection, and structural analysis happens entirely in your browser using JSON.parse. Your data never leaves your device, which makes the validator safe for inspecting API responses, configuration files, JWT payloads, or anything else that may contain secrets.

What do the structure stats mean?

After successful validation the tool reports the byte size, line count, maximum nesting depth, total number of keys, and a breakdown of how many objects, arrays, strings, numbers, booleans, and nulls the document contains. These figures help you spot oversized payloads, unexpectedly deep nesting, or schema drift between two versions of the same response.

Can the validator handle large JSON files?

Yes, within the limits of your browser's memory. Multi-megabyte payloads validate in milliseconds on a modern device. For extremely large files (tens of megabytes or more) a streaming command-line tool like jq is more efficient, since browser parsers load the whole document into memory at once.

Does the validator check against a JSON Schema?

Not yet. This tool checks syntactic validity (is it well-formed JSON?), not semantic validity against a schema (does it match a contract?). For schema validation, look for a JSON Schema validator that accepts a Draft 2020-12 schema along with the instance document.

Part of our growing tool belt — all client-side, all free.