JSON Validator

A JSON validator parses your text with a real JSON parser and reports the first place the grammar breaks. Paste {"a": 1, "b": 2,} here and the badge flips to Invalid with the message "Expected double-quoted property name in JSON at position 16 (line 1 column 17)" - the trailing comma. Valid input is reprinted in Formatted Output; the sample document shrinks from 323 B to 221 B when you press Minify.

✓ Valid ✗ Invalid
Error:
Indent:
Keys
Objects
Arrays
Values
Depth

Embed this tool on your website

× px

                        

💡 Integration Tip

Copy the embed code and paste it into your website HTML. The responsive version adapts to all screen sizes automatically.

0 ratings

About JSON Validator

This validator runs your text through the browser's own JSON parser, so what passes here is what a JavaScript runtime, a REST client or a config loader will accept. The badge next to the JSON Input label switches between Valid and Invalid as you type. When it fails, the error line quotes the parser message and the byte position, then adds the line and column it maps to - enough to put the cursor on the comma, quote or brace that broke the document.

When the text parses, Validate and Format reprints it into Formatted Output with 2, 4 or 8 space indentation, Minify strips every optional space onto one line, and Sort Keys rewrites every object with its keys in alphabetical order, recursively. The size shown beside each box is the real byte size: the built-in sample is 323 B formatted and 221 B minified. The stats strip counts keys, objects, arrays and values and the maximum nesting depth - 13 keys, 4 objects, 1 array, 12 values and depth 3 for that same sample. JSON Path Query walks a dotted expression such as $.config.theme or $.tools[1] and prints the value it lands on, or undefined when the path does not exist.

The grammar it enforces is RFC 8259, so the things people most often paste are rejected on purpose: comments, trailing commas, single-quoted strings, unquoted keys, NaN and Infinity. Two documents pasted back to back (newline-delimited JSON) fail with "Unexpected non-whitespace character after JSON". Two behaviours are worth knowing: RFC 8259 says names within an object SHOULD be unique but does not forbid duplicates, so {"a":1,"a":2} is reported valid and the last value wins, and integers outside the interoperable range the RFC gives, -(2^53)+1 to (2^53)-1, are rounded to the nearest IEEE 754 double.

This is a syntax validator, not a schema validator: it will not check your document against a JSON Schema, an OpenAPI definition or an Avro schema, and it does not repair broken input for you. Everything runs in the page, so nothing you paste leaves the browser.

Use Cases

A backend developer pastes an API response that a client library rejected, reads the position in the error line, and finds the trailing comma a templating step left behind before the payload ever reaches the parser.
A DevOps engineer checks a hand-edited configuration file before a deploy: the badge confirms it parses, and the depth figure in the stats strip shows the nesting is still what the loader expects.
A technical writer preparing a documentation snippet runs Sort Keys so every example object appears in the same alphabetical order across the whole page, then copies the formatted output straight into the docs.
A QA engineer pastes a captured response and types $.config.theme into JSON Path Query to pull one field out of a deeply nested body instead of scrolling through it in the browser devtools.
A front-end developer shrinking a bundled data file presses Minify and compares the two byte figures beside the boxes to decide whether the saving is worth losing a readable diff.

How to use

1

Paste the JSON you want to check into the JSON Input box, or press the clipboard button in the button row to load the built-in sample document.

2

Watch the badge beside the JSON Input label: it flips between Valid and Invalid on every keystroke, and the red line underneath names the fault and its position.

3

Choose 2, 4 or 8 spaces on the Indent row, then press Validate and Format to print the indented document into Formatted Output.

4

Press Minify to put the document on one line, or Sort Keys to rewrite every object with alphabetically ordered keys, nested objects included.

5

Read the stats strip for keys, objects, arrays, values and the maximum nesting depth, and compare the byte sizes shown beside the input and output boxes.

6

Type an expression such as $.config.theme or $.tools[1] into JSON Path Query to pull a single value out, then use the copy button to take the output away.

Pro Tips

  • The position in the error message is a character offset into what you pasted, and the line and column that follow are derived from it. Count from the start of the box, not from the start of your original file.
  • Duplicate keys do not fail. Paste {"a": 1, "a": 2} and the badge says Valid, the output prints "a": 2 and the stats strip counts one key - a silent way to lose data that a schema validator would catch.
  • IDs longer than 15 digits change. 12345678901234567890 is reprinted as 12345678901234567000, because the parser stores it as a double. Keep long identifiers as strings before they reach any JSON tool.
  • Sort Keys is recursive, so it reorders nested objects as well as the top level. It is the fastest way to make two versions of the same config comparable in a line diff.
  • The clipboard button beside JSON Input loads a sample document if you just want to see the tool work; the bin button next to it clears input, output, stats and the error line in one go.

Troubleshooting

Problem:

The badge says Invalid and the message is "Expected double-quoted property name in JSON".

Solution:

A comma is followed by nothing usable - almost always a trailing comma before a closing brace or bracket. Pasting {"a": 1, "b": 2,} reports position 16, line 1, column 17. Delete the last comma. JSON allows no trailing comma even though JavaScript object literals do.

Problem:

The message is "Expected property name or '}' in JSON at position 1".

Solution:

The first key is not a double-quoted string. Both {'a': 1} and {a: 1} produce this at position 1. JSON has no single-quoted strings and no bare keys; convert every key and every string value to double quotes. A // or /* */ comment before the first key gives the same message at the comment.

Problem:

The message is "Unexpected non-whitespace character after JSON".

Solution:

The first document ended and another one started. Pasting {"a":1} and {"b":2} on two lines reports position 8, line 2, column 1. That is newline-delimited JSON, which is a stream of documents rather than one document: validate the lines one at a time, or wrap them in [ ] separated by commas.

Problem:

The document is reported valid but a key has vanished from the output.

Solution:

The object contained the same name twice. RFC 8259 says names within an object SHOULD be unique but does not require it, and this parser keeps the last one: {"a": 1, "a": 2} prints "a": 2 and the stats strip counts a single key. Search the source for the repeated name; nothing on this page will warn you about it.

Problem:

A long numeric ID comes back with different digits at the end.

Solution:

Numbers are parsed as IEEE 754 doubles, so 12345678901234567890 is reprinted as 12345678901234567000. RFC 8259 only guarantees interoperability for integers between -(2^53)+1 and (2^53)-1. Quote long identifiers as strings at the source; no formatting option here can recover the lost digits.

Frequently Asked Questions

It is a tool that runs your text through a JSON parser and tells you whether it conforms to the grammar in RFC 8259, and where it stops conforming. This page shows a Valid or Invalid badge beside the input, the parser message with the character position of the first fault, and - when the document parses - a reformatted copy plus a count of keys, objects, arrays, values and nesting depth.

Paste the document into the JSON Input box. Validation runs on every keystroke, so the badge changes to Valid or Invalid without pressing anything. If it is invalid, the red line under the box names the problem and the position; fix it in place and the badge flips. If it is valid, press Validate and Format to get an indented copy in Formatted Output.

An object, an array, a string in double quotes, a number, true, false or null - nested to any depth. Keys must be double-quoted strings. What is not allowed: comments, a comma after the last element, single quotes, unquoted keys, NaN, Infinity, and a second document after the first. Each of those produces a distinct error message here, so the red line tells you which rule you hit.

RFC 8259 defines no comment syntax, so a strict parser has to reject one. Pasting {"a": 1} with a // note line above the key gives "Expected property name or '}' in JSON" pointing at the comment. Formats that do allow comments - JSONC in VS Code settings, JSON5, tsconfig.json - are supersets, and their tooling strips the comments before a standard parser sees the text.

No. This page checks syntax only: it answers "does this parse", not "does this match my contract". It will not verify required properties, types, enums or formats from a JSON Schema, an OpenAPI definition or an Avro schema. Use it first to prove the document is well formed, then run a schema validator - a bad schema result on unparseable input is meaningless anyway.

No, and that is deliberate. Guessing whether a stray comma should be deleted or a value inserted after it can silently change your data. What the tool does instead is put you on the exact character: the message gives the position, the line and the column, and validation reruns as you edit, so you see the badge turn green the moment the last fault is gone.

It is the browser parser's wording when the very first token is already wrong, and it echoes the offending text back at you. Pasting {"a": NaN} produces: Unexpected token 'N', "{"a": NaN}" is not valid JSON. NaN and Infinity are JavaScript number literals that RFC 8259 does not include, so encode them as null or as a string before serialising.

Open the file in any editor, select all, and paste it into the JSON Input box - the tool has no upload field, and pasting keeps the file off the network entirely. The byte size shown beside the box confirms the whole file arrived; if it is smaller than the file on disk, your editor truncated the selection rather than the tool truncating the input.

VS Code validates any file it recognises as JSON and underlines faults in the editor, and its JSONC mode additionally tolerates comments in settings files. Notepad++ needs the JSON Viewer plugin from Plugins Admin before it will parse. Both work on a file you already have open; this page is for the payload you just copied out of a log, a terminal or a browser network tab.

There is no fixed cap, because parsing happens in your own browser tab and the limit is that tab's memory. Documents of a few hundred kilobytes are instant. Multi-megabyte files still parse, but validating on every keystroke makes typing feel heavy, so paste them, read the result, and edit the source in a real editor instead of in the box.

Popular Tools

No more tools to show
Explore All Tools
FreeWebTools AI
Powered by free AI models · Full chat →