โ JSON Validator
By Shihab Mia ยท Updated 2026-08-04
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, counting both objects and arrays as they open. 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.
Browser-based validation does have a practical limit: because everything runs client-side with the built-in parser, a file of a few hundred kilobytes to a few megabytes checks instantly, but a multi-hundred-megabyte export (a database dump or a log archive) can make the tab slow or unresponsive since the entire string has to sit in memory before JSON.parse can even begin. For payloads at that scale, validate with a streaming parser in your own codebase or split the file first. It is also worth noting that this tool checks a single JSON document, not newline-delimited JSON (NDJSON) or JSON Lines, where every line is its own separate JSON value; those need validating one line at a time or with a tool built for that format.
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.
- Verifying a payload copied from a browser DevTools console, an API testing tool, or a server log is intact JSON before you save it, diff it, or feed it into a script.
How to use the JSON Validator
- Paste or type your JSON into the input box. A sample is pre-filled so you can see a valid result straight away.
- Read the status line: a green message means valid JSON, a red message means the JSON validator found a syntax error.
- 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.
- When it is valid, pick your indent (2 spaces, 4 spaces or tab) and review the pretty-printed output.
- Press Copy to put the formatted JSON on your clipboard, or Clear to start over with a new payload.
Formula & method
Worked examples
A small valid object: {"name":"Ada","skills":["math","code"],"address":{"city":"London"}}.
- JSON.parse succeeds, so the status turns green and reads "Valid JSON. The top-level value is a object."
- Top-level keys = 3 (name, skills, address).
- Total keys = 4: the 3 root keys plus the 1 key (city) inside the nested address object. Array items are not counted as keys.
- 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,}.
- JSON.parse throws because JSON does not allow a comma after the last property.
- The validator catches the error and reads the engine message, for example "Expected double-quoted property name in JSON at position 13".
- Position 13 is converted to a line and column so you can see the comma is at the end of the object.
- 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.
Nested data mixing arrays and objects: {"items":[{"id":1},{"id":2,"tags":["x","y"]}]}.
- JSON.parse succeeds since every bracket and quote is balanced, so the status is green.
- Top-level keys = 1: just the items key at the root.
- Total keys = 4: the 1 root key, plus 1 key (id) in the first array item, plus 2 keys (id and tags) in the second array item. The array items themselves and the two strings inside tags are not counted, only object keys are.
- Max depth = 4: the root object opens level 1, the items array opens level 2, the second item object opens level 3, and its tags array opens level 4.
Result: Valid JSON, 1 top-level key, 4 total keys, max depth 4, showing how arrays add to nesting depth even though they do not add to the key count.
Valid JSON value types the validator accepts
| Type | Example | Notes |
|---|---|---|
| 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 |
| Number | 42 or -3.14 or 1e5 | No leading zeros, no NaN or Infinity |
| Boolean | true or false | Lowercase only |
| Null | null | Lowercase only, not None or nil |
Common things that look like JSON but fail validation
| Mistake | Bad | Fix |
|---|---|---|
| Trailing comma | {"a":1,} | {"a":1} |
| Single quotes | {'a':1} | {"a":1} |
| Unquoted key | {a:1} | {"a":1} |
| Comment | {"a":1} // note | Remove the comment |
| JS literal | {"a":undefined} | {"a":null} |
Escape sequences allowed inside a JSON string
| Sequence | Meaning | Example use |
|---|---|---|
| \" | Double quote | To include a literal " inside a string |
| \\ | Backslash | A Windows path like C:\\Users needs each backslash doubled |
| \/ | Forward slash | Optional, mainly seen in JSON embedded inside HTML |
| \n | Line feed | A new line inside a string value |
| \t | Tab character | A tab inside a string value |
| \uXXXX | Unicode code point | Any character by its 4-digit hex code, for example \u00e9 for e with an accent |
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.
- Assuming duplicate keys are caught as an error. JSON syntax technically allows repeating a key, so {"a":1,"a":2} passes validation without a warning. JSON.parse silently keeps only the last value and drops the earlier one, so if two people merge objects and end up with a duplicate key, this validator (like every standard parser) will not flag it, only your own tests will catch the lost data.
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, without counting array items themselves. Max depth is how many objects and arrays are stacked inside each other. They help you gauge the size and shape of a payload at a glance.
Can this tool automatically fix or repair broken JSON?
No, and that is deliberate. Automatic JSON repair has to guess at your intent, such as which quote to close or which comma to drop, and that guess can quietly change your data. This validator only tells you exactly where the JSON breaks, with a precise line and column, so you fix the real cause yourself instead of trusting an automated guess.