My Tool Studio
Developer

JSON Validator

This JSON validator checks whether your JSON is valid as you type and, when it is not, highlights the line and tells you the column and a plain-English reason, such as a missing comma or a single-quoted string. Press Go to error to jump straight to it. Fix common errors removes trailing commas and comments, switches single quotes to double quotes and quotes bare keys in one go, and Format or Minify tidies the JSON once it passes. Valid JSON is still checked for duplicate keys and numbers too large for JavaScript. Tick the JSON Schema option to test the structure too. Paste, drop, upload or load from a URL. The check runs in your browser.

Always freeNo sign upRuns in your browser

Result

Paste JSON or press Try sample. The result shows here.

How to use

01

Add the JSON

Paste into the JSON to check box, drop or upload a .json file, or use Load URL. Try sample loads a broken example with a single-quoted string, a trailing comma and an unquoted key.

02

Read the result

Validation runs as you type. Invalid JSON highlights the line and shows the column, a reason and the nearby lines with a caret. Valid JSON shows its type, depth, size and any warnings.

03

Fix, format or check a schema

Press Go to error or Fix common errors, then Format or Minify. To check fields and types, tick Also validate against a JSON Schema and paste your schema.

Why JSON Validator

Common JSON errors and how to fix them

Most invalid JSON comes from a short list of mistakes, usually made while editing a file by hand or copying an object from JavaScript or Python code. The validator explains each of these in plain words, and the ones marked auto-fix are handled by the Fix common errors button.

ErrorExampleFix
Trailing comma{"a": 1,}Delete the comma after the last item (auto-fix)
Single quotes{'a': 'b'}Use double quotes for keys and strings (auto-fix)
Unquoted key{a: 1}Wrap the key in double quotes (auto-fix)
Comment// note or /* note */Remove it, since JSON has no comments (auto-fix)
Python literalsTrue, False, NoneUse true, false and null (auto-fix)
Missing comma{"a": 1 "b": 2}Add a comma between the two items
Leading zero{"zip": 02134}Quote it as a string: "02134"
Line break inside a string"line one, then Enter"Write the break as \n inside the string
NaN or Infinity{"x": NaN}Use null or a real number (auto-fix writes null)

How the validator finds the error

Validation happens in two passes. First, your browser's own JSON parser reads the text. If it succeeds, the JSON is valid and the result shows its type, nesting depth and size in characters and UTF-8 bytes. Because this is the same parser your front-end code uses, a pass here means JSON.parse will accept it too.

If the browser parser fails, a second, stricter reader walks through the text from the start. It tracks every opening brace and bracket, every key and value, and stops at the first character that breaks the rules. That position is turned into a line and column, and the reader describes what it expected at that point, such as a comma or a closing brace.

The raw message from your browser is shown as well, because browsers word their errors differently and some give no position at all. Only the first error is reported, since everything after it could be misread once the structure is broken.

After a successful parse, two more checks run on the raw text. Duplicate keys are reported because JSON.parse keeps only the last one without saying so, and number literals longer than JavaScript can store are flagged before they are silently rounded. The Standard menu can also enforce the older RFC 4627 rule that the top level must be an object or an array.

Common questions

Why is my JSON invalid?
The most common causes are a comma after the last item, single quotes, a key without quotes, a comment, or a missing comma between two items. The validator points to the first of these with its line and column. Fix it and validate again, because parsing stops at the first error.
Are trailing commas allowed in JSON?
No. The JSON standard (RFC 8259) does not allow a comma after the last item in an object or array. JavaScript and JSON5 do allow it, which is why it slips into hand-edited files. Fix common errors removes trailing commas for you.
Can JSON use single quotes for strings or keys?
No. JSON strings and keys must use double quotes. Fix common errors converts single-quoted strings to double-quoted ones and escapes any double quotes that were inside them.
How do I find the line with a JSON error?
Look at the editor: the line with the error is highlighted in red and its number is marked in the gutter. The result also names the line and column and shows the nearby lines with a caret under the character. Press Go to error to move the cursor there.
What is the difference between JSON and JSON5?
JSON5 is a looser format that allows comments, trailing commas, single quotes, unquoted keys and extra number forms such as hex and Infinity. Most APIs and JSON.parse accept only standard JSON. This validator checks standard JSON. Fix common errors converts most JSON5 habits and turns NaN and Infinity into null, but it leaves hex numbers for you to change.
What does the JSON validator's Fix common errors button change?
It removes trailing commas, // and /* */ comments and a leading byte order mark, turns single-quoted strings into double-quoted ones, wraps bare property names in quotes, replaces True, False and None with true, false and null, and writes NaN, Infinity and undefined as null. It does not guess missing commas or brackets, because the right fix depends on what you meant. A message lists each kind of fix it applied.
Does the JSON validator warn about duplicate keys?
Yes. Repeated keys in the same object are legal syntax, but RFC 8259 says names should be unique and most parsers keep only the last value, so the result lists each duplicate with its line and column. It also warns when a number such as a 19-digit ID is too large for JavaScript to hold exactly.
Does the JSON validator check my data against a JSON Schema?
Yes, if you ask it to. Tick Also validate against a JSON Schema, paste the schema, and pick a draft or let it read $schema. Each rule that fails is listed with the path in your data, such as /items/0/price. The full JSON Schema Validator page adds schema generation from sample data.
Does the validator report every JSON error at once?
No. Like the JSON parser in your browser, it stops at the first error. Fix that one, press Validate again, and repeat until the result says Valid JSON.
Is it safe to validate JSON that contains API keys?
Yes. The JSON is checked by JavaScript running in your browser tab and is not sent to a server. Closing the tab clears it.

More Developer tools

View all