01 / JSON / json-validator

JSON Validator

Validate JSON and pinpoint syntax errors by line and column.

ReadyLocal processing
01 · Workspace

How to use

  1. 01Paste or type JSON into the JSON input box. A sample config is loaded so you can see the result format.
  2. 02Validation runs live as you type. There's no button to press.
  3. 03Check the badge: Valid means JSON.parse accepted the input, and Invalid JSON means it didn't.
  4. 04For valid input, read the summary line, which names the top-level type (object with its key count, array with its item count, or a primitive).
  5. 05For invalid input, read the error note. In most browsers it gives the line and column where parsing stopped, so jump there and fix the character.
  6. 06Use Copy input to grab the corrected JSON, or Clear to start over.

What is this tool?

This JSON validator checks text against the strict JSON grammar using your browser's own JSON.parse, so it accepts and rejects exactly what a JavaScript runtime would. When parsing fails, it turns the engine's character offset into a line and column number. When it succeeds, it tells you the shape of the top-level value. Validation happens entirely in your browser, and nothing you paste is uploaded.

Common JSON syntax errors and how to fix them

Most invalid JSON comes from habits carried over from JavaScript object literals. Trailing commas ({"a": 1,}) are the most common cause. Next come single-quoted strings ('value'), unquoted keys ({name: "x"}), and comments (// or /* */). Strict JSON allows none of them. The literals true, false and null must be lowercase, and NaN, Infinity and undefined are not valid values at all.

Copy-paste problems are the next biggest source. Smart quotes from a word processor or chat app, an unescaped double quote inside a string, or a raw line break inside a string value will all stop the parser. Inside a string, newlines must be written as \n and backslashes as \\.

The reported position is where the parser gave up, which isn't always where the mistake is. A missing comma usually shows up at the start of the next key, and a missing closing brace shows up at the end of the input. If the column doesn't look wrong, check the line just before it.

What "valid JSON" does and doesn't guarantee

Passing this check means the text is well-formed JSON. It doesn't mean the data matches what your API expects. The validator doesn't check required fields, value types, or a JSON Schema. A payload can be valid JSON and still fail on the server because a number was sent as a string.

A few edge cases are worth knowing. A bare value such as 42, "hello" or null is valid JSON on its own, and the summary will report it as a number, string or null. Duplicate keys are not rejected. JSON.parse quietly keeps the last value, so {"id": 1, "id": 2} validates and parses as id 2. Watch for this when an object is assembled by hand.

Common use cases

  • Checking that a request body copied from a bug report parses before replaying it in an API client
  • Finding the trailing comma or stray quote that breaks a package.json, tsconfig or .eslintrc file
  • Confirming a mocked API response fixture is well-formed before it goes into a test suite
  • Checking the top-level shape of a large export, such as an array with 1,200 items versus a wrapping object
  • Verifying JSON emitted by a logging pipeline or webhook before writing a parser for it

FAQ

How do I find the error in my JSON?

Paste it into the input. When the browser reports a character position, the tool shows the line and column where parsing failed. The real mistake is often just before that point, such as a missing comma on the previous line.

Why is my JSON invalid when it works in JavaScript?

JavaScript object literals allow trailing commas, single quotes, unquoted keys and comments, but strict JSON allows none of these. Remove them and the input should validate.

Does this validate against a JSON Schema?

No. It only checks that the text is syntactically valid JSON. It doesn't check field names, types or required properties.

Are duplicate keys an error?

Not in this tool. Like JSON.parse, it accepts duplicate keys and keeps the last value, so check hand-built objects for repeated keys yourself.

Is my JSON sent to a server?

No. Validation runs with your browser's built-in JSON parser, and the input never leaves the page.