Format JSON
Make a JSON file readable, shrink it to one line, or put every key in alphabetical order.
or drop them here · files stay on your device
We count formats and sizes. Filenames stay private unless you opt in.
- Runs on your device
- No sign-up or watermark
- No fixed file size cap
The short answer
To format JSON privately, choose one or more .json files, pick Pretty (2 spaces), Pretty (tabs) or Minified, and optionally sort the keys. Parsing and formatting run in your browser with the built-in JSON parser, so the data is never uploaded. Invalid JSON stops with the parser’s error message.
How to format JSON without sending it to a server
- STEP 1
Choose JSON files
Select or drop one .json file, or several to format them in one pass. They stay on your device.
- STEP 2
Pick a style
Choose Pretty (2 spaces), Pretty (tabs) or Minified from the Style menu.
- STEP 3
Sort keys if you want
Turn on Sort keys alphabetically to make two payloads easy to compare side by side.
- STEP 4
Copy or download
Copy the result from the preview, or download it as name-formatted.json. Several files download as a ZIP.
Why a JSON formatter needs to be private
JSON is the format most APIs speak, which means the JSON you want to read is often a live response: session tokens, email addresses, order histories. Pasting that into a formatter that posts it to a server hands it to a third party, and logs tend to outlive the reason they were kept.
Formatting itself is simple. A formatter parses the text into data, then writes it back out with consistent indentation, or with none at all. Because parsing is strict, it doubles as a validator: if the file has a trailing comma or a stray quote, it will not parse.
What survives, and what does not
Each file is parsed with JSON.parse and written back with JSON.stringify, indented by two spaces, a tab, or nothing. With Sort keys on, every object at every depth is rebuilt with its keys in alphabetical order; arrays keep their order. The report compares character counts before and after, and the preview updates as you change the style.
What you keep
Every value and the order of array items
Key order as written, unless you turn on sorting
Unicode text, emoji and escaped characters
What you lose
Comments and trailing commas: the parser is strict JSON, so files with them are rejected rather than repaired
Precision on integers above 9,007,199,254,740,991, such as some 64-bit IDs, which are rounded by JavaScript numbers
Duplicate keys: only the last value for a repeated key survives
Honest limits are published on every tool page. If a tool cannot do something well, it says so here rather than letting you find out after the download.
Format JSON at a glance
| Input | JSON |
|---|---|
| Output | JSON (pretty, tab-indented or minified) |
| Batch | Yes, several files at once |
| Parser | Browser built-in JSON.parse (strict) |
| Runs on | Your device, in the browser |
| Works offline | After the first use |
If something goes wrong
It says the file is not valid JSON
The message includes the parser’s reason and usually a position. Common causes are trailing commas, single quotes, comments, or a file that is really JSON Lines with one object per line.
A long number changed in the output
Integers beyond 2^53 cannot be held exactly by JavaScript, so they are rounded. Keep such IDs as strings in the source if you need them exact.
Format JSON questions
Is there a JSON formatter that does not send data to a server?
This one. The file is read and formatted inside your browser tab and there is no upload endpoint. Open DevTools, watch the Network panel and format a file: no request carries your data.
How do I pretty print a JSON file?
Choose the file, leave Style on Pretty (2 spaces) or pick tabs, and copy or download the result. Several files can be formatted together.
How do I minify JSON?
Pick Minified in the Style menu. All indentation and line breaks are removed, and the report shows how many characters were saved.
Can it sort JSON keys alphabetically?
Yes. Sort keys alphabetically reorders the keys of every object, including nested ones. Array order is left alone, because it usually means something.
Does it validate JSON as well?
In effect, yes. Formatting needs a successful parse, so a broken file stops with the parser’s error instead of producing output. It does not check against a JSON Schema.
Can I paste JSON instead of choosing a file?
Not yet. The tool works on files, so save the text as a .json file first. The formatted result can then be copied straight from the preview.