JSON formatter: format and beautify JSON online, free and private
A JSON formatter, also called a JSON beautifier or pretty printer, adds line breaks and indentation to JSON so a person can read it. To format JSON free and privately, paste it into Input JSON or click Upload JSON File, and the indented result appears below as you type, with syntax highlighting. Everything runs in your browser; nothing is uploaded, and you can confirm that in the Network tab of DevTools.
Many online formatters read the text with JSON.parse and write it back with JSON.stringify, which quietly changes the data. An integer such as 1234567890123456789 turns into 1234567890123456800, 10.50 becomes 10.5, and 1e400 becomes null. This formatter checks the text against the JSON standard (RFC 8259) and then copies the original numbers, strings and key order digit for digit, so only the whitespace changes.
If the text is not valid JSON, you get the line, column and a plain-English fix instead of a vague error. To check a document without reformatting it, use the JSON validator; to shrink it, use the JSON minifier.
Table of Use: JSON inputs and what you get
| You paste | Setting | You get |
|---|---|---|
| {"name":"Ada","tags":["a","b"]} | Indent Size: 2 spaces (default) | Seven indented lines, with keys and strings in different colors |
| {"name":"Ada","tags":["a","b"]} | Indent Size: 4 spaces, or Tab | The same seven lines, indented four spaces or one tab per level |
| {"b":1,"a":{"d":1,"c":2}} | Sort keys alphabetically | a before b, and c before d inside it. Order is by character code, at every level |
| {"id":1234567890123456789,"price":10.50} | Default | Digits unchanged, 10.50 stays 10.50, and a "Kept exactly" note names the large integer |
| {"a":1,"a":2} | Default | Both a keys kept in the output, with a "Duplicate keys" notice |
| {"a":1,} | Any | Error: Trailing comma before '}' at line 1, column 7, with the fix |
| {'a':1} | Any | Error: Property names must use double quotes, not single quotes |
| // note, then {"a":1} | Any | Error: Comments are not allowed in JSON |
| $.store.book[?(@.price < 10)].title | JSONPath Query, then Run query | The titles of books priced under 10, as a JSON array |
Once the JSON is readable, you can move it into another format with the JSON to CSV converter, the JSON to YAML converter or the JSON to XML converter.
Features
- Formats as you type. There is no Format button. A "Formattingโฆ" note shows while a large paste is being processed.
- Strict validation with readable errors. Each error gives the line and column, the offending line with a caret, a How to fix hint and a Show in input button.
- Lossless output. Numbers, strings and key order are copied as written. Numbers too large for JavaScript get a "Kept exactly" note, and duplicate keys are kept and listed.
- Indent Size. 2 spaces, 4 spaces or Tab.
- View Mode. Formatted text, or a collapsible Tree View with Collapse all and, for documents up to 20,000 nodes, Expand all.
- Sort keys alphabetically. Applies at every level, in character-code order, so digits and capital letters come first.
- Search. Highlights matching lines in the formatted output and steps through them with Enter, Shift+Enter or the arrow buttons.
- JSONPath Query. Supports property names, array indexes and slices, wildcards, recursive descent
.., unions and filters such as[?(@.price < 10)]. Up to 10,000 matching values are returned as a JSON array you can copy, and the Matched paths list shows the first 500 paths. - Upload JSON File, Load example, Undo, Redo, Copy, Download, Clear. Files up to 25 MB are read on your device. Undo and Redo keep the last 100 snapshots of your input.
- Show line numbers. A checkbox that turns the gutter on or off.
It accepts strict JSON only: comments, trailing commas, single quotes and unquoted keys are rejected, and the tool does not repair them for you. Tree View is read-only. To compare two versions of a file, use the text diff tool.
How to format JSON, step by step
- Paste your JSON into Input JSON, click Upload JSON File to choose a .json, .txt or .geojson file, or click Load example to try a sample.
- Under Indent Size choose 2 spaces, 4 spaces or Tab. The result updates straight away.
- Tick Sort keys alphabetically if you want keys ordered, and untick Show line numbers if you do not need the gutter.
- If a red Invalid JSON panel appears, read the message and the How to fix line, then click Show in input to jump to the problem.
- Read the result under Formatted JSON, or set View Mode to Tree View and open the parts you care about. Use the search box to find a key or value.
- To pull out specific values, type an expression into JSONPath Query and click Run query.
- Click Copy for the clipboard, Download to save formatted.json, Undo and Redo to step through earlier input, or Clear to start over.
Who can use it
- Back-end and API developers reading responses and logs, then testing patterns against them in the regex tester.
- Front-end developers checking the shape of data before writing code, and tidying the surrounding script with the JavaScript beautifier.
- QA engineers and support staff inspecting payloads from bug reports without installing anything.
- Data analysts exploring exports and GeoJSON files, or bringing spreadsheet data across with the CSV to JSON converter.
- People moving between formats, such as XML users who start with the XML to JSON converter and then format the result here.
- Students learning JSON syntax, helped by the error messages.
FAQs
How do I format JSON online?
Paste your JSON into Input JSON, or click Upload JSON File. The indented version appears below it as you type, with syntax highlighting, so there is no Format button. Pick 2 spaces, 4 spaces or Tab under Indent Size, then click Copy, or Download to save it as formatted.json.
Why does my JSON not format?
The tool formats only valid JSON, so a syntax error stops it and a red panel appears instead. It gives the line and column, shows the line with a marker under the problem, and says how to fix it. Common causes are a trailing comma, single quotes, unquoted keys, comments, and True, None or undefined. Show in input jumps to the spot.
Will formatting change my numbers or key order?
No, not by default. Formatters built on JSON.parse and JSON.stringify round integers above 9,007,199,254,740,991, so 1234567890123456789 becomes 1234567890123456800, and they rewrite 10.50 as 10.5. This formatter copies every number, string and key exactly as written and changes only whitespace, unless you tick Sort keys alphabetically. Duplicate keys are kept and flagged.
What is JSONPath and how do I use it here?
JSONPath is a query language for picking values out of JSON, much as XPath does for XML. Type an expression such as $.store.book[*].author or $..book[?(@.price < 10)].title into the JSONPath Query box and click Run query. The matches appear as a JSON array you can copy, along with the path of each match.
What is the difference between Formatted and Tree View?
Formatted shows the JSON as indented text with syntax highlighting, line numbers and a search box. Tree View shows a collapsible hierarchy so you can open only the objects and arrays you need. Documents with more than 2,000 nodes start collapsed, and long lists load 200 items at a time. Both views read the same data.
How large a JSON file can I format?
Upload JSON File accepts files up to 25 MB. The viewer draws only the lines on screen, so scrolling a large result stays smooth. Very deep nesting, thousands of levels, is the exception: the indentation alone can outgrow what a browser can hold, so the tool tells you and suggests Tree View or the JSON minifier instead.
Is it safe to paste JSON with API keys or personal data?
The formatting is plain JavaScript running in your browser, so what you paste is never uploaded or stored by ZipConvert. You can verify it in the Network tab of your browser DevTools: no request carrying your JSON is sent while you type or format. Even so, treat live secrets with care and rotate any you have pasted anywhere.
What is the difference between formatting and minifying JSON?
Formatting adds line breaks and indentation so people can read the data. Minifying removes all optional whitespace so the file is as small as possible for storage or transfer. The data is identical either way. Format when you want to read or debug JSON, and minify when you want to ship it.