← All TOOLZORQ tools · More guides
Short answer: to check if your JSON is valid, paste it into a JSON validator such as TOOLZORQ's free JSON Formatter and click Validate. If it is valid, the tool will accept it; if it is not, fix the reported error — usually a stray comma, single quotes, or an unquoted key — and check again.
JSON is the plain-text format that carries data between systems: from a server to a web page, from one app to another, from a configuration file into a program. It looks simple — curly braces, square brackets, a few colons and commas — and that is exactly why it is so easy to break. One comma in the wrong place, one quote mark facing the wrong way, and the whole document is rejected.
This guide explains how to check if your JSON is valid, how to read the result, and how to fix the seven errors that cause almost every failure. It uses TOOLZORQ's free JSON Formatter throughout, which runs entirely in your browser with no sign-up.
JSON stands for JavaScript Object Notation. It is a text format for storing and exchanging structured data, built from a small set of pieces: objects (key-value pairs inside curly braces), arrays (ordered lists inside square brackets), strings (text inside double quotes), numbers, and three special values — true, false, and null. A small example shows all of them at once:
{
"name": "Aisha Khan",
"age": 34,
"subscribed": true,
"tags": ["reading", "cycling"],
"address": null
}
The rules for JSON are written down in a standard called RFC 8259, published by the Internet Engineering Task Force. "Valid" simply means the text follows those rules exactly. A computer reading JSON cannot guess what you meant or work around a mistake: if the text breaks even one rule, the whole document is invalid, and the program that tried to read it will stop and report an error.
Valid JSON is not the same as sensible JSON. A validator checks the shape of the text, not its meaning. This is valid JSON, even though a negative price and a stock status of "maybe" are plainly wrong as data:
{ "price": -50, "in_stock": "maybe" }
Checking validity is the first step: it tells you the document is readable. Whether the data inside it is correct is a separate question, and one only a person can answer.
The JSON Formatter is a free tool that runs entirely in your browser. You paste your JSON in, and it can format it, shrink it, or check it. There is no sign-up, and nothing you paste is uploaded anywhere. Here is the whole process:
That loop — check, fix, check again — is the whole workflow, and the next section covers what to look for.
Almost every invalid JSON document fails for one of seven reasons. Learn to spot them and you will fix most broken JSON in seconds.
The commonest error of all. A comma after the last item in an object or array looks natural — it is allowed in JavaScript and Python — but JSON forbids it. The rule is simple: commas separate items; they never follow the last one.
{
"name": "Aisha",
"age": 34,
}
The fix: delete the comma after the last item.
{
"name": "Aisha",
"age": 34
}
JSON strings must use double quotes. Single quotes are valid in JavaScript and Python, so anyone writing JSON from memory reaches for them — and JSON rejects them.
{ 'name': 'Aisha', 'age': 34 }
The fix: replace every single quote with a double quote.
{ "name": "Aisha", "age": 34 }
Be careful with text that contains an apostrophe, such as "O'Brien". Inside a double-quoted string the apostrophe is fine as it is: "name": "O'Brien" is valid JSON.
In JSON, every key in an object must be a string in double quotes. JavaScript allows unquoted keys in object literals, which is why this mistake is so easy to make when copying code into a JSON file.
{ name: "Aisha", age: 34 }
The fix: put double quotes around every key.
{ "name": "Aisha", "age": 34 }
{ "name": "Aisha", "age": 34 }
If you are copying a JavaScript object into a JSON file, this is the first thing to check. The values may be fine; the keys are where the error hides.
JSON has no comments. The // and /* */ comment styles from JavaScript and other languages are not part of the JSON standard, and a validator will reject any document that contains them.
{
"name": "Aisha", // user's full name
"age": 34
}
The fix: remove the comments entirely before checking or sending the JSON.
{
"name": "Aisha",
"age": 34
}
If you need to leave a note, put it outside the JSON. Some configuration formats that look like JSON, such as JSONC or JSON5, do allow comments, but plain JSON does not.
Every item in an object or array must be separated from the next by a comma. Miss one, and the validator stops at the point where the comma should have been.
{
"name": "Aisha"
"age": 34
}
The fix: add the missing comma after each item except the last.
{
"name": "Aisha",
"age": 34
}
This error often appears after editing: you add a new line to an object and forget the comma on the line above it.
Every opening brace { needs a closing brace }, and every opening bracket [ needs a closing bracket ]. They must also close in the right order: the last one opened is the first one closed, like nested boxes. A missing or misplaced closing character breaks the whole document.
{
"name": "Aisha",
"tags": ["reading", "cycling"
}
The fix: close each bracket and brace in the correct order.
{
"name": "Aisha",
"tags": ["reading", "cycling"]
}
This is the hardest of the seven to spot by eye in a long document. Work through the structure from the outside in: count the opening braces and brackets, count the closing ones, and find the pair that does not match.
JSON has exactly three special values: true, false, and null, all written in lower case. Values from other languages look similar but are not JSON, and a validator rejects them all.
{ "active": True, "score": NaN, "note": undefined }
The fix: use the JSON forms. Python's True and False become true and false; Python's None becomes null. undefined has no JSON equivalent — use null or leave the key out. NaN and Infinity are not allowed in JSON at all; use null, a number, or a string instead.
{ "active": true, "score": null, "note": null }
This error almost always comes from copying data out of another language. Python dictionaries use True, False, and None; JavaScript code uses undefined. None of those are JSON, even though the surrounding shape looks identical.
| Error | What it looks like | The fix |
|---|---|---|
| Trailing comma | "age": 34, before } | Delete the comma after the last item |
| Single quotes | 'name': 'Aisha' | Use double quotes for all strings |
| Unquoted keys | { name: "Aisha" } | Put double quotes around every key |
| Comments | // note inside the JSON | Remove comments entirely |
| Missing comma | Two items with no comma between them | Add a comma after each item except the last |
| Mismatched brackets | { or [ left unclosed | Close every bracket and brace in the right order |
| Wrong values | True, None, undefined, NaN | Use true, false, and null |
Once your JSON is valid, the JSON Formatter gives you two ways to present it: Format and Minify. They change how the text looks, not what it means — both outputs describe exactly the same data.
Format beautifies the JSON: it adds line breaks and indentation so each key and value sits on its own line and nested structures are easy to follow. Use it when a person needs to read the JSON — when you are debugging, reviewing an API response, or checking a configuration file by eye.
Minify does the opposite: it removes every space, line break, and indentation that is not needed, compressing the whole document onto one line. The result is smaller and faster to send over a network, which is why minified JSON is what machines usually exchange. Use it when you need to paste JSON into a field with a size limit or send it in a request.
When you format, you also choose the indent spacing — how many spaces each level of nesting is pushed in by. Two spaces is the commonest choice and keeps the document compact; four spaces is easier to read when the nesting runs deep. There is no right answer, only the one that reads best for you and your team. Pick one spacing and use it consistently. If you are contributing to an existing project, match the spacing that project already uses.
One warning: formatting or minifying only works on valid JSON. If the document has an error, fix it first — the Format and Minify buttons cannot repair broken text. Validation comes first; presentation comes second.
JSON rarely breaks in a textbook. It breaks in the middle of real work, usually in one of four places.
API responses. A program asks a server for data and gets JSON back — or gets something that is almost JSON. The commonest failure is a server returning an error page written in HTML instead of the expected JSON. If your validator rejects a whole API response, look at the first few characters: if they are <!DOCTYPE or <html>, the server sent an error page, and the problem is on the server side, not in your JSON.
Configuration files. Many programs read their settings from JSON files, and a single typing mistake can stop the program from starting at all. This is where trailing commas and comments cause the most trouble, because people edit config files by hand. After editing a config file, validate it before restarting the program — it takes ten seconds.
JavaScript object literals. JavaScript objects look like JSON but follow looser rules: single quotes, unquoted keys, trailing commas, comments, and undefined are all fine in a JavaScript object literal. That makes copying code into a JSON file a reliable way to produce invalid JSON. If your JSON came from JavaScript code, check it against the seven errors above before anything else, starting with the quotes and the keys.
Python dictionaries. The same trap exists in Python. A Python dictionary printed out looks almost identical to JSON, but it uses True, False, and None where JSON needs true, false, and null, and it allows single quotes and trailing commas. The correct way to turn a Python dictionary into JSON is to use Python's own JSON tools, which produce proper JSON; copying printed output by hand is not it.
In all four cases the fix is the same: validate the exact text, find the first error, fix it, and validate again.
JSON often carries sensitive data — API keys, user records, private settings, tokens. TOOLZORQ's JSON Formatter runs entirely in your browser: the text you paste never leaves your device, is never sent to a server, and is never stored. You can safely validate a configuration file containing a password or an API response containing a token, because no copy of it travels anywhere.
If you are validating a document that contains a live secret — a real API key or password — replace it with a placeholder such as REDACTED before pasting, and put the real value back afterwards. The validator only checks the shape of the text, so a placeholder validates exactly the same way.
Paste it into a JSON validator such as TOOLZORQ's free JSON Formatter and click Validate. The tool checks the text against the JSON rules and reports whether it is valid. If it is not, fix the first error it reports and validate again until it passes.
A trailing comma — a comma after the last item in an object or array. It is allowed in JavaScript and Python, so people type it without thinking, but JSON forbids it. If a validator points at a closing brace or bracket, check the character just before it for a stray comma.
No. Plain JSON has no comments, and the // and /* */ styles from other languages will make a document invalid. If you need to leave a note, put it outside the JSON. Formats such as JSONC and JSON5 do allow comments, but they are not plain JSON.
Because the JSON standard, RFC 8259, says so: strings and keys must be written in double quotes. Single quotes are valid in JavaScript and Python, which is why people use them by habit, but a JSON parser will reject them.
Format adds line breaks and indentation so a person can read the JSON easily; Minify removes all unnecessary spaces and line breaks so the file is as small as possible. Both describe the same data. Neither can fix invalid JSON; validate first.
Yes, it is free, with no sign-up, and it runs entirely in your browser. Nothing you paste is uploaded to a server or stored anywhere, so private data and tokens never leave your device.