JSON Validator
Paste JSON to check it, see the exact line and column of any error, then format, minify or copy it.
input.json
Validation runs as you type, in your browser. Nothing is uploaded.
Indent
What makes JSON invalid
JSON is stricter than JavaScript object syntax. One stray character stops the whole document from parsing, so these rules all have to hold:
- Keys and strings use double quotes:
{"name": "value"}, never single quotes or bare keys. - Commas go between items only. A comma before
]or}is an error. - There are no comments, neither
//nor/* */. - The literals are lowercase
true,falseandnull. - Numbers are plain decimals: no
NaN,Infinity, leading zeros, leading+or hex. - Inside strings, a backslash starts an escape (
\n,\",\u00e9), and raw tabs or line breaks are not allowed. - A document holds exactly one top-level value.
Common JSON errors and how to fix them
- Trailing comma. JSON does not allow a comma before ] or }. Delete the last comma in the list or object. See npm ERR! code EJSONPARSE in npm and Error: Invalid JSON syntax in Terraform.
- Single quotes. Keys and strings need double quotes. Replace 'value' with "value". See Error: Unexpected token } in JSON at position 123 (malformed package.json) in Node.js.
- Unquoted key. Every object key is a double-quoted string: write {"name": 1}, not {name: 1}.
- Missing comma. Two values or members sit next to each other. Add a comma between them.
- Comment. JSON has no comments. Remove the // or /* */ comment, or keep notes in a separate field.
- Python or JavaScript literal. JSON only knows lowercase true, false and null. True, None, NaN, Infinity and undefined are not JSON. See Invalid JSON text in PostgreSQL.
- Unexpected end of input. The input stops before the JSON is complete: a closing bracket, brace or quote is missing, or the text was cut off. See npm ERR! Unexpected end of JSON input in npm.
- HTML instead of JSON. The input starts with <, so it is HTML (often an error page or a 404) rather than JSON. Check the URL or the server response. See SyntaxError: Unexpected token < in JSON at position 0 in React and SyntaxError: Unexpected token < in JSON at position 0 (express.json() failed) in Node.js.
- Invisible or smart-quote character. A byte order mark, zero-width space, non-breaking space or curly quote is in the input. Delete it or retype the quote as a plain ". See npm ERR! Unexpected token in JSON at position in npm and Error parsing JSON: invalid character in Terraform.
- Invalid escape. Inside a string, a backslash must start \" \\ \/ \b \f \n \r \t or \u followed by four hex digits. Write a literal backslash as \\.
- Raw control character in a string. Strings cannot contain a raw tab or line break. Write \t or \n instead.
- Extra data after the JSON. A JSON document holds one top-level value. Remove what follows it, or wrap several values in an array.
- Unexpected character. This character is not allowed here. Check for leading zeros, a + sign, a missing colon or a stray character.
FAQ
- Is my JSON uploaded anywhere?
- No. Validation, formatting and minifying run in your browser, and the JSON you paste never leaves the page.
- Why does my browser word the error differently?
- The message shown is your browser's own JSON.parse error, and Chrome, Firefox and Safari each phrase it their own way. The line and column come from a separate check of the text, so they are the same in every browser.
- Are comments or trailing commas allowed?
- No. JSON5 and JSONC (used by some config files) allow them, but they are not JSON, and a JSON parser rejects both.
- Are duplicate keys invalid?
- RFC 8259 allows them, so the validator accepts them, but most parsers keep only the last value. Rename one of the keys if both values matter.
- Does formatting change my numbers?
- No. The formatter keeps the original text of every number and string, so 12345678901234567890 or 1.0 stays exactly as written.