Shipping an AI app or agent? Security review in 1 working day: $149 / ₹13,900. Request a review →
AI Review Ready
Home / Free tools / JSON formatter
Free tool · no sign-up

JSON formatter and validator

Paste JSON to format, minify or validate it. Errors show the line and column. Nothing leaves your browser.

The JSON rules that break most often

From RFC 8259:

  • Strings and keys use double quotes. Single quotes are invalid.
  • No trailing commas after the last item in an object or array.
  • No comments. // and /* */ are not part of JSON.
  • Only true, false and null as literals, in lowercase. No undefined, NaN or Infinity.
  • Control characters inside strings (like a raw line break) must be escaped (\n).

Is my data safe?

Formatting and validation use your browser's built-in JSON parser. The text is never sent anywhere, so API keys and tokens in the JSON stay on your device. Still, rotate any secret you pasted into a site you don't control.

JSON.parse error messages, and what each one means

Paste the failing JSON above: the formatter shows the line and column. Below are the exact messages from Chrome and Node.js (V8, checked in Node.js 24 on 1 Dec 2026) and, where known, Firefox. Older Chrome versions said Unexpected token } in JSON at position 12 instead.

Chrome / Node.jsFirefoxUsual causeFix
Unexpected token '<', "<!DOCTYPE "... is not valid JSON-Your code parsed an HTML page (an error page, a 404 or a login redirect) instead of JSON, often fetch() followed by response.json().Check the response status and Content-Type before parsing; log the first 200 characters of the body.
Unexpected end of JSON inputJSON.parse: unexpected end of dataEmpty or cut-off text: an empty response body (for example a 204 No Content) or a truncated file.Check the body isn't empty before parsing.
Expected double-quoted property name in JSON at position 7 (line 1 column 8)JSON.parse: expected double-quoted property nameA trailing comma after the last item of an object: {"a":1,}Remove the comma.
Unexpected token ']', "[1,]" is not valid JSONJSON.parse: unexpected characterA trailing comma in an array.Remove the comma.
Expected property name or '}' in JSON at position 1 (line 1 column 2)JSON.parse: expected property name or '}'Single-quoted keys, {'a':1}: JavaScript object syntax, not JSON.Use double quotes, or build the text with JSON.stringify().
Expected ',' or '}' after property value in JSON at position 7 (line 1 column 8)-A missing comma between properties, or a comment (//) inside the JSON.Add the comma; remove comments (JSON has none).
Unexpected token 'u', "{"a":undefined}" is not valid JSON-undefined, NaN or a function as a value.Use null, a number or a string.
Unexpected non-whitespace character after JSON at position 7 (line 1 column 8)-Two JSON values back to back, {"a":1}{"b":2}, for example a JSON Lines file read as one document.Parse it line by line, or wrap the values in an array.

Related: JWT decoder · password generator

Sources