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

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.

FAQ

Does JSON allow comments?
No. Standard JSON has no line or block comments. JSON.parse will 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.

Related tools