JSON Formatter and Validator
Pretty-print with a 2-space indent, minify, or validate JSON using JSON.parse and JSON.stringify. Your data stays in the browser.
JSON format, minify, and validate
What is JSON?
JSON (JavaScript Object Notation) is a lightweight, text-based way to exchange data. It uses objects ({ }) made of comma-separated key-value pairs, arrays ([ ]), strings in double quotes, numbers, booleans (true / false), and null.
JSON is the default format for many REST APIs and configuration files because it is easy for humans to read and for programs to parse. Browsers and servers often send JSON in HTTP request and response bodies.
Common JSON errors
- Trailing commas — A comma after the last property or array element is invalid in JSON. Remove it or let your editor flag it.
- Unquoted keys — Keys must be double-quoted strings.
{ name: "Ada" }is JavaScript; JSON requires"name". - Single quotes — JSON strings and keys use double quotes only. Single-quoted strings will not parse.
JSON vs JavaScript objects
JSON is a serialization format: a string that follows strict rules. A JavaScript object literal is syntax in source code; it can include features JSON does not allow.
- JSON has no
undefined, functions, orSymbolkeys. - JSON does not allow comments or trailing commas.
JSON.parse(text)turns valid JSON text into JavaScript values;JSON.stringify(value)turns supported values into JSON text.
FAQ
- Does JSON allow comments?
- No. Standard JSON has no line or block comments.
JSON.parsewill throw if it sees//or/* */. - Why does JSON.parse fail on trailing commas?
- The JSON grammar does not allow a comma after the final entry in an object or array. Many JavaScript engines accept trailing commas in object literals, but JSON is stricter.
- Can I use single quotes for JSON strings?
- No. Keys and string values must use double quotes. Single quotes are a common mistake when copying from informal JavaScript examples.
- Is JSON the same as a JavaScript object?
- JSON is text. After parsing, you get ordinary JavaScript values. Object literals in code can include syntax and values that are not valid in JSON.