JSON Validator

Result—
Error—
Top-level keys—
Nesting depth—

How JSON Validator is calculated: Valid JSON = parses with JSON.parse without error; error position = the character index where the parser stopped.

What is a JSON validator?

JSON is the plain-text format that carries data between apps, APIs, and config files. It looks simple — curly braces, quoted keys, commas between values — but it has strict rules, and one wrong character makes the whole block unreadable. A JSON validator answers a single question: does this text follow the JSON rules, or not?

The need comes up daily for anyone who works with data. An API returns an error payload and you need to know whether the payload itself is broken or your code is broken. A config file stops loading and you need to find the one bad line. A colleague pastes a block into chat and you need to know if it is safe to use. In each case the validator gives a yes-or-no answer in a second.

This validator does more than say yes or no. It shows the exact error message and the character position where the parser stopped, so you can jump straight to the problem instead of scanning the whole block. It also counts the top-level keys and measures the nesting depth, which tells you the shape of the data at a glance.

Everything runs in your browser. Your JSON never leaves your device, nothing is uploaded or stored, and there is no account to create. You can paste sensitive data — API keys, user records, private config — without worrying about who else sees it.

How JSON validation works

The validator feeds your text to the JSON parser built into every browser. The parser reads the text character by character, checking each one against the JSON grammar: an object must start with a brace, keys must be double-quoted strings, values must be strings, numbers, true, false, null, objects, or arrays, and pairs must be separated by commas.

If the parser reaches the end of the text without a problem, the JSON is valid. If it hits a character that cannot appear where it appears, it stops and reports the position — the character index, counted from the start of the text. That position is the most useful part of the error, because the mistake is almost always at that exact spot or one character before it.

The key count is simpler: it counts the keys of the top-level object only. The default text on this page, {"name":"Ada","age":36}, has 2 top-level keys. Depth is the deepest level of nesting — the default has depth 1, because its values are plain strings and numbers with no objects or arrays inside them.

One thing a validator cannot tell you is whether the JSON means what you think it means. Valid JSON can still have the wrong field names, the wrong types, or missing data. Validation checks the shape of the text, not the sense of the data — that part is still your job.

Reading the error messages

The most common error is the trailing comma. {"name":"Ada",} looks fine, but the comma after the last value is illegal in JSON, and the validator reports an error at character 14 — the closing brace that follows the comma. Remove the comma and the same text parses. This one mistake accounts for a large share of all invalid JSON.

The second common error is an unquoted key. {name: "Ada"} is valid JavaScript, but it is not valid JSON, and the validator reports an error at character 1 — the letter n where a double quote was expected. JSON demands double quotes around every key, with no exceptions, so add the quotes and it parses.

The third is single quotes around strings. {'name': 'Ada'} fails for the same reason: JSON strings must use double quotes. This trips up people who write Python or JavaScript all day, because both languages accept single quotes. In JSON, only double quotes count.

Other errors follow the same pattern. A missing colon after a key, a number with a leading zero like 01, or the words NaN and Infinity all stop the parser at the exact spot. Read the character position, look at that spot in your text, and the fix is usually one character away.

A worked example: three blocks, three verdicts

Start with the default text on this page: {"name":"Ada","age":36}. The validator says Valid, with 2 top-level keys and a depth of 1. It is a flat object with two fields — a name and an age — and no nesting at all. That is the shape of most small config blocks and simple API responses.

Now add one comma: {"name":"Ada",}. The validator says Invalid, with the error at character 14 — the closing brace. The comma tells the parser another pair is coming, and then the brace arrives instead. Delete the comma and the block is valid again. One character is the whole difference between working and broken.

Try a nested block: {"a":{"b":[1,2,{"c":3}]}}. The validator says Valid, with 1 top-level key and a depth of 4 — the outer object, the object under a, the array under b, and the object inside the array. Deep nesting is not wrong, but it makes data harder to read, and the depth number tells you how deep you are before you start digging.

Finally, try {name: "Ada"}. The validator says Invalid, with the error at character 1. The parser expected a double quote and found the letter n instead. Add quotes around the key and the block parses. Three blocks, three verdicts, and each error message points at the exact spot to fix.

Who checks JSON, and when

Developers are the biggest users. Every API returns JSON, every config file is JSON, and every log line with structured data is JSON. When an integration breaks, the first question is always whether the data is broken or the code is broken — and a validator answers it in a second, before any debugging starts.

Testers and support staff are the second group. They read JSON when something goes wrong: a failed import, a broken sync, a strange error in a ticket. The validity check tells them which side of the problem to look at, and the key count tells them whether the payload even has the fields it should have.

Data workers are a third group. Analysts move JSON between systems all day — exports, imports, feeds, and files. A quick validity check before an import saves a failed run and a confusing error log. It takes two seconds and it catches the kind of mistake that wastes an afternoon.

Students and hobbyists are a fourth group. Anyone learning to code meets JSON in the first month, and a validator is the fastest way to learn its rules. Paste a block, read the error, fix the spot, and the rule sticks — because you found the mistake yourself instead of reading about it.

JSON validator vs JSON formatter

A validator and a formatter are close cousins, but they answer different questions. The validator asks whether the text is legal JSON. A JSON formatter takes legal JSON and prints it neatly, with each key on its own line and each level indented. Use the validator when something is broken; use the formatter when something is hard to read.

The natural workflow is validate first, then format. If the JSON is invalid, formatting cannot fix it — the formatter will show you the same error. Check validity here, fix the spot the error points to, and only then format the clean result. That order saves time, because formatting broken JSON is a dead end.

Other tools in the same family move JSON around instead of checking it. A base64 encoder decoder turns JSON into a single safe string for transport, which is useful when JSON has to travel inside a URL or a header. But encoding cannot fix invalid JSON either — the same rule applies: validate first, then move it.

Counting the size of the text is a separate job again. A word counter tells you how big a block is, and a text formatter cleans up plain text, but neither one knows the JSON rules. Each tool does one job well, and the validator's job is the yes-or-no question.

Common mistakes that break JSON

The trailing comma is the classic. {"a":1,} is invalid JSON — the comma after the last value is an error. JavaScript allows it; JSON does not. Remove the comma and it parses. If your editor adds commas automatically when you press enter, check the last line of every object and array.

Second: single quotes around strings. JSON demands double quotes. {'a': 1} is invalid; {"a": 1} is valid. If your JSON came from a Python script or a hand-written note, check the quotes first — it is the most common cause of a confusing error message.

Third: comments. JSON has no comments. A // note or a /* block */ inside JSON is an error, even though it works in JavaScript. If your config file has comments, strip them before pasting. Config formats that look like JSON but allow comments are not JSON — they are something else wearing JSON's clothes.

Fourth: pasting JSON with invisible characters. Copying from some editors adds a hidden byte-order mark at the start of the text, and the parser rejects it. If the validator says invalid and the JSON looks fine, paste it into a plain text editor first, then copy it back. The hidden characters disappear and the block parses.

How to use this JSON validator

Using this JSON validator is simple. Paste your JSON into the box, or type it directly. The verdict appears instantly above the box: Valid or Invalid, with the error message and character position when it fails, plus the key count and nesting depth when it passes. There is no button to press and no form to submit.

When the verdict is Invalid, read the character position first. Count to that spot in your text — or paste the text into an editor that shows character positions — and look at what sits there. The mistake is almost always that character or the one just before it. Fix it, and the verdict flips to Valid.

Everything runs in your browser. No sign-up, no account, no data sent anywhere — your JSON never leaves your device. It works offline once the page has loaded, so you can use it on a plane, in a server room with no signal, or anywhere else you debug.

Try it with something real before you need it. Paste an API response, or a config file, and read the verdict. Once you have used it twice, checking JSON becomes a reflex — and the next time an integration breaks, you will know in two seconds whether the data is at fault. Valid JSON is the first step — if the JSON is structured data, our JSON-LD validator checks the @context, @type and required fields as well.

Frequently Asked Questions

It checks whether the text follows the JSON grammar: quoted keys, double-quoted strings, commas in the right places, and matching braces and brackets. It does not check whether the data makes sense — valid JSON can still have wrong field names or missing values. Think of it as a spell-checker for structure, not for meaning.

JSON forbids a comma after the last value in an object or array, so {"a":1,} is invalid. JavaScript allows trailing commas, which is why the mistake is so common. The validator points at the closing brace after the comma — delete the comma and the same text parses.

It means the parser stopped at the 14th character of your text (counting from 0), because that character cannot appear where it appears. The mistake is almost always at that exact spot or one character before it. For example, in {"name":"Ada",} the error is at character 14, the closing brace that follows the illegal trailing comma.

Yes. Everything runs in your browser — your JSON is never uploaded, stored, or sent anywhere. You can paste sensitive data like API keys or user records without worrying about who sees it, and the page works offline once it has loaded.

More free tools

More calculators and utilities from Sortrun — free, no sign-up.