ToolNimba

โœ… JSON Validator

Shihab Mia By Shihab Mia ยท Updated 2026-06-27

Ready. Paste JSON above and press Validate JSON.

This JSON validator checks whether the text you paste is valid JSON and tells you exactly what is wrong when it is not. Valid input shows a green pass message, a pretty-printed and indented copy you can grab in one click, and quick stats for top-level keys, total keys and maximum nesting depth. Invalid input shows a red error with the parser message and the line and column of the problem. Everything runs in your browser, so nothing you paste is ever uploaded.

What is the JSON Validator?

JSON (JavaScript Object Notation) is the most common way that web applications, APIs and config files exchange structured data. It is built from a small set of pieces: objects wrapped in curly braces with "key": value pairs, arrays wrapped in square brackets, strings in double quotes, numbers, the literals true, false and null, and nothing else. A JSON validator parses that text against these rules and reports the first place where the syntax breaks. Because the format is so strict, a single stray comma or a missing quote is enough to make an entire payload unreadable to the machine that receives it.

Under the hood this tool does what a real program does: it calls the browser native JSON.parse inside a try/catch block. If parsing succeeds, the input is valid JSON by definition, since JSON.parse implements the same ECMA-404 standard that every server and language follows. If parsing throws, the validator catches the error, surfaces the engine message, and converts the character position into a human-friendly line and column so you can jump straight to the offending bracket or comma. This is the same check your code performs at runtime, which is why a green result here means your data will load cleanly in production too.

Beyond a simple pass or fail, a good JSON checker helps you understand the shape of your data. After a successful parse this tool walks the parsed structure and reports three numbers: the count of top-level keys (or array items), the total number of keys across every nested object, and the deepest level of nesting. Those figures are handy when you are reviewing an API response, comparing two payloads, or sanity-checking that an export contains roughly the records you expected. The pretty-printed output then re-indents the whole thing with two or four spaces (or tabs), which turns a minified one-line blob into something a person can actually read and review.

It is worth being clear about what a JSON validator does and does not guarantee. Validating syntax confirms that the text is well-formed JSON, but it does not confirm that the data is correct for your application. A payload can be perfectly valid JSON and still be missing a required field, use the wrong data type for a value, or carry a typo in a key name. For those deeper checks you need schema validation (for example JSON Schema), which is a separate step. This tool focuses on the first and most common gate: is the JSON syntactically valid, and if not, where exactly is the error.

The most frequent reason valid-looking text fails to parse is that it is not actually strict JSON. Trailing commas after the last item, single quotes instead of double quotes, comments, unquoted keys and JavaScript style values like undefined or NaN are all things people write by habit, and all of them are rejected by the standard. The validator points to the exact spot so you can fix it, and once it is clean the formatter gives you a canonical version that other tools and teammates will accept without complaint.

When to use it

  • Checking an API response or webhook payload that is failing to load, and finding the exact character where the JSON breaks.
  • Validating a config file (package.json, tsconfig.json, a CI workflow) before you commit it, so a stray comma does not break a build.
  • Cleaning up a minified one-line blob into a readable, indented version you can review or paste into documentation.
  • Confirming that a hand-edited JSON snippet is still well-formed after you tweaked a value by hand.
  • Inspecting the shape of unfamiliar data: how many keys it has and how deeply it is nested before you write code against it.

How to use the JSON Validator

  1. Paste or type your JSON into the input box. A sample is pre-filled so you can see a valid result straight away.
  2. Read the status line: a green message means valid JSON, a red message means the JSON validator found a syntax error.
  3. If it is invalid, use the line and column in the error to jump to the problem (often a trailing comma or a missing quote) and fix it.
  4. When it is valid, pick your indent (2 spaces, 4 spaces or tab) and review the pretty-printed output.
  5. Press Copy to put the formatted JSON on your clipboard, or Clear to start over with a new payload.

Formula & method

The method is a single strict parse: result = JSON.parse(text) wrapped in try/catch. If it returns, the text is valid JSON (per the ECMA-404 standard) and the validator pretty-prints it with JSON.stringify(value, null, indent). If it throws, the input is invalid and the caught error message is shown; any "position N" in that message is converted to a 1-based line and column. Stats are computed by walking the parsed value: top-level keys = number of keys (or array items) at the root, total keys = sum of object keys at every depth, max depth = the deepest level of nested objects and arrays.
How the JSON validator works1. Paste JSONtext input2. JSON.parsetry / catchValid JSONformat + statsInvalid JSONerror + line/colsuccessthrowsRuns entirely in your browser. Nothing you paste is uploaded.

Worked examples

A small valid object: {"name":"Ada","skills":["math","code"],"address":{"city":"London"}}.

  1. JSON.parse succeeds, so the status turns green and reads "Valid JSON. The top-level value is a object."
  2. Top-level keys = 3 (name, skills, address).
  3. Total keys = 4: the 3 root keys plus the 1 key (city) inside the nested address object. Array items are not counted as keys.
  4. Max depth = 2: the root object is level 1, and the address object sits one level deeper at level 2.

Result: Valid JSON, 3 top-level keys, 4 total keys, max depth 2.

Invalid input with a trailing comma: {"a":1,"b":2,}.

  1. JSON.parse throws because JSON does not allow a comma after the last property.
  2. The validator catches the error and reads the engine message, for example "Expected double-quoted property name in JSON at position 13".
  3. Position 13 is converted to a line and column so you can see the comma is at the end of the object.
  4. Remove the trailing comma to get {"a":1,"b":2} and the status turns green.

Result: Invalid JSON flagged at the trailing comma, with line and column shown.

Valid JSON value types the validator accepts

TypeExampleNotes
Object{"id": 1, "ok": true}Keys must be double-quoted strings
Array[1, 2, 3]Ordered list, any value types mixed
String"hello"Double quotes only, never single quotes
Number42 or -3.14 or 1e5No leading zeros, no NaN or Infinity
Booleantrue or falseLowercase only
NullnullLowercase only, not None or nil

Common things that look like JSON but fail validation

MistakeBadFix
Trailing comma{"a":1,}{"a":1}
Single quotes{'a':1}{"a":1}
Unquoted key{a:1}{"a":1}
Comment{"a":1} // noteRemove the comment
JS literal{"a":undefined}{"a":null}

Common mistakes to avoid

  • Leaving a trailing comma after the last item. JavaScript allows {"a":1,} but JSON does not. A comma after the final property or array element is the single most common reason a JSON validator reports an error. Delete it and re-validate.
  • Using single quotes instead of double quotes. JSON strings and keys must use double quotes. Text like {'name':'Ada'} is invalid; it has to be {"name":"Ada"}. This often happens when copying object literals out of JavaScript or Python code.
  • Adding comments. Standard JSON has no comment syntax, so // and /* */ both cause a parse error. If you need comments, use a format like JSON5 or JSONC, but a strict JSON validator (and most parsers) will reject them.
  • Wrapping a number or boolean in quotes by accident. A value like "true" or "42" is a valid JSON string, not a boolean or a number. The JSON stays valid, but the type is wrong for your code. The validator confirms syntax, so watch the types yourself.
  • Pasting a JavaScript object instead of JSON. Unquoted keys, single quotes, undefined, NaN and trailing commas are legal JavaScript but invalid JSON. If you copied an object from code, it usually needs quoting before it will validate.

Glossary

JSON
JavaScript Object Notation: a strict, text-based format of objects, arrays, strings, numbers, booleans and null used to exchange data between systems.
Validation
Checking that text follows the JSON syntax rules so a parser can read it. Valid means well-formed, not necessarily correct for your app.
JSON.parse
The browser and JavaScript function that turns a JSON string into a real value, throwing an error if the text is not valid JSON.
Pretty-print
Re-formatting JSON with consistent indentation and line breaks so a person can read it, the opposite of minifying.
Key
The quoted name on the left of a colon inside a JSON object, for example "name" in "name": "Ada".
Nesting depth
How many levels of objects or arrays are stacked inside each other; a flat object is depth 1, an object inside it is depth 2.
JSON Schema
A separate standard for describing the required shape of JSON (fields, types, constraints), used to validate meaning beyond raw syntax.
ECMA-404
The official standard that defines the JSON grammar; every conforming parser, including the one this tool uses, follows it.

Frequently asked questions

How do I validate JSON online?

Paste your JSON into the box above. This JSON validator parses it instantly in your browser and shows a green message if it is valid or a red error with the line and column if it is not. Nothing is uploaded, so it is safe for private data.

What makes JSON invalid?

The usual culprits are a trailing comma after the last item, single quotes instead of double quotes, unquoted keys, comments, and JavaScript values like undefined or NaN. Any of these will make the JSON syntax checker report an error at the exact spot it fails.

Does this JSON validator format the JSON too?

Yes. It is a JSON validator and formatter in one: when the input is valid it pretty-prints an indented copy you can adjust to 2 spaces, 4 spaces or tabs, then copy with one click. Invalid input shows the parser error instead.

How do I read the JSON parse error?

The error shows the message from the parser plus the line and column of the problem, for example "position 13 (line 1, column 14)". Go to that spot in your text and look for a missing quote, an extra comma, or an unclosed bracket just before it.

Is my data sent to a server when I check JSON online?

No. The validation runs entirely in your browser using the native JSON.parse function. Nothing you paste leaves the page, which makes it safe to check JSON online even for sensitive API keys or private payloads.

What is the difference between a JSON validator and JSON lint?

They do the same core job: a JSON lint or JSON checker confirms your text is well-formed JSON and points out syntax errors. This tool also reports stats (key counts and nesting depth) and gives you a formatted copy, which a plain linter may not.

Can a JSON validator check that my data is correct, not just valid?

A validator only checks syntax. Your JSON can be perfectly valid yet still miss a required field or use the wrong type. To enforce a required shape you use JSON Schema validation, which is a separate step beyond this syntax check.

Why does my JavaScript object fail JSON validation?

JavaScript object literals allow unquoted keys, single quotes, trailing commas and values like undefined, none of which are valid JSON. Convert the object to strict JSON (double-quoted keys and strings, no trailing commas) and it will validate.

What do the top-level keys, total keys and max depth numbers mean?

Top-level keys counts the keys or array items at the root. Total keys sums the object keys across every level of nesting. Max depth is how deeply objects and arrays are stacked inside each other. They help you gauge the size and shape of a payload at a glance.