JSON Formatter & Validator

Turn a one-line JSON blob from an API response or a log into readable, indented JSON — or strip the whitespace to minify it. If the JSON is invalid, you get the line and column of the error.

What is JSON?

JSON (JavaScript Object Notation, RFC 8259) is a plain-text format for structured data built from objects, arrays and a handful of value types. It is easy for humans to read and every mainstream language can parse it, so it is the default format for web APIs and for config files such as package.json.

TypeExample
String"Alice" (double quotes only)
Number30, 3.14, -1e10
Booleantrue, false
Nullnull
Array[1, 2, 3]
Object{"a": 1}

Formatting {"name":"Alice","age":30,"tags":["admin","dev"]} with 2-space indentation gives:

{
  "name": "Alice",
  "age": 30,
  "tags": [
    "admin",
    "dev"
  ]
}

Common JSON syntax errors

ProblemInvalidValid
Trailing comma{"a": 1,}{"a": 1}
Single quotes{'a': 1}{"a": 1}
Unquoted key{a: 1}{"a": 1}
Comments// noteNot allowed in JSON
undefined / NaN{"a": undefined}{"a": null}

Trailing commas and comments are accepted by JavaScript object literals and by “JSON with comments” formats such as JSONC or JSON5, but not by a standard JSON parser.

Format JSON in code and on the command line

ToolPretty-printMinify
jqjq . data.jsonjq -c . data.json
Pythonpython3 -m json.tool data.jsonpython3 -m json.tool --compact data.json
JavaScriptJSON.stringify(obj, null, 2)JSON.stringify(obj)
PHPjson_encode($v, JSON_PRETTY_PRINT)json_encode($v)

Frequently asked questions

Why do the last digits of a large number change?

JavaScript numbers are 64-bit floating point and represent integers exactly only up to 253 − 1 (9007199254740991). A larger integer is rounded when parsed — 9007199254740993 becomes 9007199254740992. If you need exact large IDs, send them as strings.

What is “Sort keys” for?

It orders object keys alphabetically at every level of nesting. Sorting two documents before comparing them makes a diff show only real differences, not differences in key order.

Can it decode \uXXXX escapes?

Yes. Formatting parses the JSON, so escapes such as é are shown as the actual character (é). To convert escapes in plain text, use the Unicode escape tool.

Is it safe to paste an API response?

The JSON is parsed and formatted in your browser and is not sent to any server. Still, be careful where you paste tokens or personal data in general.