Pretty-print JSON with every number exact, or repair broken JSON: quotes, commas, comments
Paste messy or minified JSON and get it indented and easy to read. Every number stays as written, and a click on a line shows its path.
How to use it
Paste JSON, drop a .json file on the input, or click Try sample. Pick the indent (2, 3, 4 or Tab) and turn on Sort keys to put the keys of every object in A to Z order. The result appears as you paste. Click any line of the result to see its path, such as $.items[0].price. Not quite JSON? Turn on Repair: quotes, commas, comments, unquoted keys and Python’s True and None are fixed, each change listed with its line. Copy the result, or download it as formatted.json.
Examples
Pretty-print an API response
{"user":{"id":7,"tags":["a","b"]},"ok":true}{
"user": {
"id": 7,
"tags": [
"a",
"b"
]
},
"ok": true
}Sort keys, keep the numbers
{"price": 1.50, "id": 12345678901234567890}{
"id": 12345678901234567890,
"price": 1.50
}A formatter built on JSON.parse prints 12345678901234567000 and 1.5 here.
Repair a JavaScript object
{id: 7, name: 'Ada', tags: ['a', 'b',], active: True}{
"id": 7,
"name": "Ada",
"tags": [
"a",
"b"
],
"active": true
}With Repair on; the list above the result names each of the 9 changes, such as "Line 1, column 2: Put quotes around the key id."
What formatting changes
Sort keys orders the keys inside every object, at every depth. Arrays keep their order, because in JSON their order is part of the data. Numbers are copied as written: 1.50 stays 1.50 and 12345678901234567890 keeps all 20 digits. Duplicate keys are kept, both of them, in the order they came. Minify does the opposite and puts everything on one line.
Repairing almost-JSON
Single, backtick and curly quotes become double quotes; keys without quotes get them. Missing commas and colons are added; trailing and doubled commas, // and /* */ comments are removed. True, False and None become true, false and null; NaN, Infinity and undefined, which JSON has no way to write, become null. Unclosed strings, arrays and objects are closed; a ``` code fence or a JSONP callback(…) around the value is taken off; several values in a row go into one array. Numbers keep their digits; only +1, .5, 5. and hex like 0x1F are rewritten as JSON writes them.
Formatting in code
JSON.stringify(JSON.parse(text), null, 2); // numbers become doubles: 12345678901234567890 → 12345678901234567000, 1.50 → 1.5
Sources: jq 1.7 manual: number precision, Python docs: json.tool
Reading big JSON
Keys and tokens in the JSON
Questions
- Is my JSON uploaded?
No. Everything runs in your browser, so your JSON stays on your device. Nothing you paste is uploaded unless you share a result, which is locked with your password first. We don’t save or log what you paste, so API responses with tokens or customer data don’t reach us. - Why do my big numbers stay exact here?
Most formatters read JSON with JavaScript’s JSON.parse, which turns 12345678901234567890 into 12345678901234567000 and 1.50 into 1.5. This formatter keeps the digits of each number as written, so 64-bit IDs and prices are not changed. - Does Sort keys change my data?
Only the order of keys inside objects, which JSON gives no meaning to (RFC 8259). Arrays keep their order. - What happens if my JSON is not valid?
It is not formatted. You see the line, the column and the reason, with the lines around it, and Show in input puts the cursor on the spot. Turn on Repair to have quotes, commas and comments fixed for you, each change listed. - How large a file can I format?
Up to 10 MB, counted in bytes; a larger file is not read, which keeps the page quick on phones too.