JSON formatter and beautifier
Pretty print or minify JSON. JSON Mill never rewrites your numbers, reorders your keys or drops duplicates.
Formatting happens on this device. Your JSON is never uploaded. How your data stays local.
Problems
JSON Mill's formatter pretty prints or minifies JSON by changing only the whitespace between tokens. Every number, string and key is copied from your input character for character, so large IDs keep all their digits, 1.50 stays 1.50, escapes such as \u00e9 stay escaped, and keys keep their order, duplicates included.
Many formatters parse JSON into JavaScript values and print it back, which silently rounds numbers past 15 or 16 significant digits and drops repeated keys. JSON Mill does not, and it runs in your browser, so nothing is uploaded.
How to format JSON
- Paste or open your JSON. Paste it into the source panel or drop a file on the workspace. The formatted result appears in the result panel as soon as you stop typing.
- Choose the style. Press Format (Ctrl+Enter, or Cmd+Enter on a Mac) for indented output, or Minify (Ctrl+Shift+M) for one compact line. Pick 2 spaces, 4 spaces or tabs for indentation.
- Copy or download. Press Copy to put the whole result on your clipboard, or Export and JSON, formatted or JSON, minified to download it as a file.
Example: formatting without changing values
A minified record with a 20-digit ID, a price with a trailing zero, a number in exponent form and an escaped character.
{"id":12345678901234567890,"price":1.50,"grams":1.0E3,"name":"Caf\u00e9 \"Nord\"","tags":["a","b"],"empty":{}}
{
"id": 12345678901234567890,
"price": 1.50,
"grams": 1.0E3,
"name": "Caf\u00e9 \"Nord\"",
"tags": [
"a",
"b"
],
"empty": {}
}
Only whitespace changed. JSON.parse followed by JSON.stringify would have printed the ID as 12345678901234567000, the price as 1.5, the weight as 1000 and the name with a literal é. JSON Mill keeps each of them exactly as written.
Options
| Option | What it does |
|---|---|
| Format | Indented output, one value per line. Empty objects and arrays stay on one line as {} and []. |
| Minify | Removes all whitespace between tokens and keeps every token as written. |
| Indent | 2 spaces, 4 spaces or tabs. |
| Copy | Copies the full result, even when the result panel shows only the first part of a very large document. |
Limits
- The formatter does not sort keys, remove duplicate keys or normalize numbers. It reports duplicate keys as warnings so you can fix them yourself.
- Invalid JSON is not formatted. JSON Mill shows where the first error is; JSON repair can fix common mistakes such as trailing commas.
- A byte order mark at the start of the file is removed from the output, and the status line says so.
- For very large documents the result panel shows the first 2 MB; Copy and Export use the whole result.
- Documents nested many thousands of levels deep are not pretty printed, because the output would be enormous. Minify still works on them.
Questions
- How do I pretty print JSON without changing large numbers?
- Use a formatter that works on the text, not on parsed values. JSON Mill's formatter only changes whitespace, so a number such as
12345678901234567890is copied digit for digit. Formatters that useJSON.parseround it to12345678901234567000. - Does formatting change the order of keys?
- No. Keys stay in the order they appear in your JSON. If an object repeats a key, both entries are kept in place and JSON Mill shows a warning for the duplicate.
- What is the difference between Format and Minify?
- Format adds line breaks and indentation so people can read the JSON. Minify removes all optional whitespace to make the file as small as possible for sending or storing. Both keep the values exactly the same.
- Is a JSON beautifier the same as a formatter?
- Yes. Beautifier, pretty printer and formatter are names for the same thing: adding indentation and line breaks to JSON so it is readable.
- Is my data uploaded?
- No. JSON Mill processes your JSON in your browser, in a background worker on your device. Nothing leaves your device unless you choose to save or share a document, which needs an account, and JSON Mill tells you before it sends anything. How your data stays local explains how to check this yourself in your browser's developer tools.
Related tools
Last updated