Skip to content
LocalOnly

JSON Validator

Stable

Validate JSON syntax and pinpoint the exact line and column of any error.

Everything is processed locally in your browser

About JSON Validator

The JSON Validator checks whether your document conforms to the JSON specification and, when it does not, tells you precisely where and why it fails. Instead of a vague 'unexpected token', you get the line, column, and character that broke parsing. Use it to debug malformed API payloads, config files, and copy-pasted snippets in seconds.

Features

  • Precise error reporting with line, column, and character offset
  • Plain-language explanations of common mistakes like trailing commas
  • Instant re-validation as you edit the input
  • Detects duplicate keys and other subtle structural issues
  • Confirms the top-level type (object, array, string, number, and more)
  • Works on documents of any size supported by your browser

How to use JSON Validator

  1. 1

    Paste your JSON

    Add the JSON you want to check into the input editor.

  2. 2

    Read the result

    A clear pass or fail badge appears immediately, along with any error details.

  3. 3

    Jump to the error

    If validation fails, the reported line and column point you straight to the problem.

  4. 4

    Fix and re-check

    Correct the issue and the validator re-runs to confirm the document is now valid.

Examples

Catching a trailing comma

The validator reports the exact position of the invalid token.

Input

{
  "name": "Grace",
  "team": "Compilers",
}

Output

Invalid JSON: unexpected "}" at line 4, column 1 (trailing comma after "Compilers").

How JSON validation works

There are two completely different questions hiding in "is this valid?"

The first is syntactic validity: does this text follow the JSON grammar? Are the braces balanced, the strings double-quoted, the commas in legal positions? That is what this tool answers, and it is a closed question with a definite yes or no. RFC 8259 defines the grammar in about two pages, which is why JSON parsers are small and why every language agrees on what is well-formed.

The second is semantic validity: is this the right JSON? Does it have the fields your API requires, are the types correct, is `age` a non-negative integer, is `email` actually an email address? Syntax checking cannot answer any of that. `{"a": 1}` is perfectly valid JSON and completely wrong as a user record.

Confusing the two is the most common reason people are surprised when a document passes validation and then breaks downstream. If you need the second kind of answer, you need a schema - which is what the JSON Schema Validator is for.

How a parser finds and reports the problem

A JSON parser is a small state machine reading one character at a time. It always knows what could legally come next: after an opening brace, either a string key or a closing brace; after a key, a colon; after a value, either a comma or a close. When it reads a character that no rule allows, it stops and reports the byte offset where the surprise happened.

That offset is then converted into a line and column by counting newlines before it. The important consequence is that the reported position is where the parser noticed the problem, which is not always where you made the mistake. A missing closing brace three levels deep is usually reported at the very end of the file, because that is the first point at which the input becomes unambiguously wrong. When the reported line looks innocent, the real error is almost always above it.

Parsing also stops at the first error rather than collecting all of them. Fixing one problem and re-running to find the next is the normal workflow, not a deficiency in the tool.

What a passing result does not promise

Valid JSON can still contain duplicate keys. The specification says the behaviour is undefined; in practice every mainstream parser keeps the last occurrence and silently discards the earlier ones. A document with `{"role":"user","role":"admin"}` validates cleanly and means something different from what a careless reader assumes.

Valid JSON can also lose information on parse. Integers above 2^53 are rounded to the nearest representable double, so a document can be well-formed and still not survive a round trip intact. And valid JSON says nothing about character encoding beyond requiring UTF-8 in interchange - a file that validates in one tool may fail in another if it carries a byte order mark.

Reference

Common parser errors and what they really mean

Wording varies between engines, but the underlying causes are a short list.

Error messageActual cause
Unexpected token } / ]A trailing comma before the closing brace or bracket
Unexpected end of JSON inputAn unclosed brace, bracket or string - the file stopped early
Unexpected token ' in JSONSingle-quoted strings; JSON requires double quotes
Unexpected token n / NA bare `NaN`, `Infinity` or an unquoted identifier
Unexpected non-whitespace character after JSONTwo documents concatenated, or NDJSON passed as a single value
Bad control character in string literalA raw tab or newline inside a string; it must be escaped as \t or \n
Unexpected token at position 0A byte order mark or stray character before the opening brace

Which tool should you use?

These tasks overlap. Here is how to pick the right one for what you are actually doing.

You need to know whether a file is well-formed
This tool. It answers the syntax question directly and points at the first failure.
The JSON parses but your API still rejects it
Syntax is not your problem. Use the JSON Schema Validator to check required fields, types and value constraints.
You want to fix the file, not just diagnose it
The JSON Formatter validates and pretty-prints in one pass, so you get the error location and a clean document together.
You are validating many files in CI
Use a command-line tool such as `jq empty file.json` in a loop. A browser tool is for interactive debugging, not for pipelines.

Use cases

  • Debugging a 400 response caused by a malformed request body
  • Verifying config files before deploying them
  • Finding a stray trailing comma or unquoted key in hand-written JSON
  • Confirming that data exported from a spreadsheet is valid JSON
  • Teaching or learning JSON syntax with immediate feedback

Troubleshooting common errors

The error points at the last line of the file, which looks fine

Why: An unclosed brace or bracket somewhere earlier. The parser only discovers the imbalance when the input runs out.

Fix: Format the document and look at the indentation. The point where nesting stops returning to the left margin is where the missing closing character belongs.

"Unexpected non-whitespace character after JSON data"

Why: The input contains more than one JSON document - typically newline-delimited JSON from a log export, where each line is a separate value.

Fix: Validate one line at a time, or wrap the lines in `[` and `]` with commas between them to make a single array.

A file that validates here is rejected by another parser

Why: Usually a byte order mark, or a strict parser refusing duplicate keys or trailing content that a lenient one tolerates.

Fix: Re-save as UTF-8 without BOM and check for duplicate keys. Strictness genuinely varies between implementations.

Validation passes but a required field is missing downstream

Why: Syntax validation cannot check for required fields. That is a schema concern.

Fix: Define a JSON Schema for the payload and validate against it. This is the single highest-value fix for recurring integration bugs.

Limitations

What this tool deliberately does not do, so you know when to reach for something else.

  • Only syntax is checked. Required fields, value types and business rules need a JSON Schema.
  • One error is reported per pass, because parsing halts at the first failure.
  • Duplicate keys do not fail validation - they collapse to the last occurrence, matching standard parser behaviour.
  • Newline-delimited JSON is not a single JSON document and will not validate as one.
  • Precision loss on integers above 2^53 is not reported, because the document is still well-formed.

Frequently asked questions

Learn more

Command Palette

Search for a tool or command