Format JSON with one consistent layout: even indentation, one value per line, your values untouched. Runs the same formatter as JSON Beautifier.
What it does
JSON Formatter rewrites JSON so a person can read it: one value per line, nested values indented and even spacing. Only spaces and line breaks change. Every name, string, number, true, false and null stays exactly as you wrote it.
Use it for JSON you keep and edit, such as a configuration file, a test fixture or an API sample, so every file has the same layout and a diff shows what you changed instead of how the lines were spaced. JSON Beautifier runs this same formatter with the same options and gives the same result; open that page when the problem is one squeezed line that is hard to read.
What it supports
- Any valid JSON: an object, a list, a string, a number, true, false or null can be the whole text.
- Strict JSON only, as the standard defines it: names and strings in double quotes, no comments, no trailing commas, no single quotes.
- Numbers are copied character by character, so 9007199254740993, 2.370, 1e400 and -0 come out exactly as they went in. Strings and names keep their original escapes, such as \u00e9.
- Indentation of 2 or 4 spaces. Line breaks in the result are always the same kind, whatever your text used. Formatting a result again gives the same text.
- “Minify” removes only the spaces and line breaks between values. Spaces inside strings are kept.
- A name repeated inside one object is kept every time, in order, with a warning. The tree marks each repeated name with “Duplicate key”.
- A string with an unpaired surrogate escape, such as \ud800, is also kept as written, with a warning.
Good to know
- Strict means strict. JSON copied from JavaScript code, from files that allow comments or from editors that add a trailing comma is refused, and the tool points at the first problem.
- Only two fixes are ever offered: removing an invisible byte order mark (BOM) at the very start of the text, and removing trailing commas. You see the change first, and nothing changes until you press “Apply correction and run again”.
- The tree appears after “Format”, not after “Minify”. If the JSON has too many values for the tree, a note replaces it and the text result is still complete.
- The formatter never fixes anything else, never guesses a missing value and never sorts or removes names.
How to use it
- Paste or type your JSON in the input box. Nothing runs while you type.
- Choose the indentation (“2 spaces” or “4 spaces”) and press “Format”. Press “Minify” instead to do the opposite: the same JSON on one line, with no extra spaces.
- Read the result next to your input. Below it, the “Tree” shows the same data as nested rows you can open and close. The first level starts open, and “Expand all” and “Collapse all” open or close every branch at once.
- Press “Copy” to put the result on your clipboard, or “Download” to save it as formatted.json (minified.json after “Minify”).
Examples
Bring a hand-edited file to one layout
Paste this JSON, edited by hand with uneven spacing, and press “Format” with “2 spaces” selected. The indentation and the spaces around colons and brackets are rebuilt, and each value gets its own line. The names, the values and their order stay as they were.
{
"name" : "Ana",
"tags":[ "a",
"b" ],
"active":true }{
"name": "Ana",
"tags": [
"a",
"b"
],
"active": true
}A trailing comma
This text has a comma right before the closing brace, which JSON does not allow. The tool stops at the first problem and points at it.
{"name": "Ana",}JSON does not allow a comma before a closing brace or bracket (trailing comma).
Line 1, column 16
Numbers and escapes stay as written
A formatter must not touch your data. Here 2.370 keeps its last zero, 9007199254740993 keeps every digit (a JavaScript number would round it) and \u00e9 stays an escape instead of becoming é.
{"price":2.370,"id":9007199254740993,"label":"caf\u00e9"}{
"price": 2.370,
"id": 9007199254740993,
"label": "caf\u00e9"
}Limits and privacy
Size limits
- Input: up to 2,000,000 bytes of UTF-8 text (about 2 MB). Accented letters and emoji take more than one byte each. Larger input is rejected.
- Result: also up to 2,000,000 bytes. If the complete result would be larger, the tool shows only an incomplete preview of the first 100,000 bytes, and that preview cannot be copied or downloaded.
- Nesting: up to 256 levels of objects and lists inside each other. Deeper JSON is refused because it is beyond what the tool processes.
- Time: a run that takes longer than its time limit is stopped. Try a smaller input.
Your privacy
The text you type or paste, or open from a local file, is processed locally in your browser, in a dedicated Web Worker. It is never uploaded or sent to the server (a file you open is read in your browser only), and it is not written to storage, cookies or the address bar.
“Copy” puts the result on your clipboard and “Download” saves it as a file, but only when you press the button. The file is created in your browser, so nothing is uploaded.
For the full details, see the Privacy Policy
Related tools and pages
Your text stays in the page when you switch tools in the same tab, so you can try the same text in another tool. Reloading or closing the tab ends it.