JSON Validator

Check JSON syntax, inspect error locations when available, and scan for duplicate keys.

Input
JSON input
Output
Result
Options

Further reading

About this tool


This validator checks whether a document is valid JSON and reports a syntax error if not, with a location when available. For valid input it describes what is in the parsed document: how deeply it nests, how many keys it contains, and whether a raw-text scan flags duplicate keys.

Duplicate key detection matters because JSON.parse discards duplicates silently. A config file containing the same key twice will parse without complaint and use only the last value, which is a genuinely hard bug to spot by eye. This tool uses a heuristic raw-text scan and lists up to 20 flagged duplicates with line numbers, plus a count of any remaining matches. Keys containing escape sequences can cause both missed duplicates and false positives, so the scan is not a complete duplicate-key check.

How to use it

  1. Paste or upload JSONDrop a file, pick one, or paste the text you want to check.
  2. ValidatePress Validate or use Ctrl+Enter.
  3. Read the resultInvalid input gives an error message and, when available, a line, column and caret. Valid input gives a structural summary.
  4. Check for duplicatesReview flagged duplicate keys and their line numbers. At most 20 are listed; escaped key names can cause missed matches or false positives.

Worked examples


Each example below is executed against this tool by the test suite, so what you see is what the tool actually produces.

Valid JSON with a duplicate key

Input

{
  "host": "localhost",
  "port": 8080,
  "port": 9090
}

Output

Valid JSON

Top-level type: an object
Total keys: 2
Objects: 1
Arrays: 0
Strings: 1
Numbers: 1
Booleans: 0
Nulls: 0
Maximum nesting depth: 2

Duplicate keys found:
  line 4: "port" (in the same object)

The counts describe the parsed document, which has two keys because JSON.parse kept only port 9090. That discarded value is exactly why the duplicate is also reported, with its line.

What to watch for


The details that decide whether a conversion is correct, and where information can be lost without any error being raised.

What counts as valid
Validation follows RFC 8259 as implemented by JSON.parse. Strings must use double quotes, keys must be quoted, trailing commas are rejected, and comments are not allowed. Any of NaN, Infinity or undefined is invalid. A bare value such as 42 or "text" is a valid JSON document on its own.
The structural summary
For valid documents you get the top-level type, counts of objects, arrays, strings, numbers, booleans and nulls, the total key count, and maximum nesting depth. Depth is useful when a consumer imposes a limit, and the type counts often reveal that a field you expected to be a number is arriving as a string.
Common errors and what causes them
A trailing comma before } or ] is a common failure, usually from hand-editing. Single-quoted strings come from pasting JavaScript object literals rather than JSON. "Unexpected end of input" means the document ended before a value or structure was complete. "Unexpected non-whitespace character after JSON" usually means extra content follows the first value. If each line contains one complete value, the file may be JSON Lines rather than a single JSON document.

Limitations


  • Checks syntax only, not conformance to a JSON Schema.
  • Reports the first syntax error rather than all of them, because parsing cannot reliably continue past a structural break.
  • Processing happens in your browser, so very large inputs are bounded by available memory. Files above roughly 10 MB are handled but will feel slower, and multi-hundred-megabyte files are better suited to a command-line tool.

Questions


Does this validate against a JSON Schema?
No. This checks JSON syntax, whether the document is well-formed. Validating that a document matches a schema (required fields, types, ranges) is a separate job.
Why does my file fail with "non-whitespace character after JSON"?
The file probably contains extra content after the first JSON value. If it holds one complete value per line, it may be JSON Lines (JSONL/NDJSON); use the JSON Lines to JSON converter for that format. Other trailing content may simply be malformed JSON.
Are duplicate keys actually invalid?
JSON syntax permits duplicate names, although the specification recommends unique names for interoperability. Parsers can handle duplicates differently; JavaScript keeps the last value. This tool can flag duplicates, but escaped key names can produce missed matches or false positives.