How to use the JSON formatter
Paste JSON into the Input box — or drag a file onto it, press Load file, or fetch it from a URL — and it is checked as you type. Press Format (or Ctrl+Enter) to pretty-print it with two spaces, four spaces or tabs, or Minify to strip every unnecessary space for the smallest payload. The output has line numbers and syntax colours that stay readable in light and dark mode, and can be copied, downloaded or moved back into the input with Use output as input.
Switch the output to Tree to browse a large document: objects and arrays expand on click, show how many keys or items they contain, and long arrays load in pages of 300 so a 50,000-item array doesn’t lock up the tab. Clicking any key copies its path, such as $.orders[1].customer, ready to paste into code.
The search box accepts a key name (every key containing that text, anywhere in the document) or a path with dots, brackets and wildcards: address.city, orders[0], orders[-1] for the last item, or $.orders[*].total to pull one field out of every element. JSON Lines files (one object per line, .jsonl or NDJSON) are recognised automatically: Minify keeps one record per line, and Format shows the records as an array.
Fetch asks your browser to download the address directly — nothing passes through our server — so it only works when that server allows other websites to read it (CORS). Many APIs don’t; in that case open the URL in a new tab and paste the result.
Reading validation errors
Browsers’ own error messages are terse (“Unexpected token } in JSON at position 1843”). This validator is written for humans: it gives the line and column (an emoji counts as one character), shows the offending line with a caret under the exact character, and explains the likely cause. The mistakes it recognises include:
- Trailing commas —
[1, 2, ]is fine in JavaScript but not in JSON. - Single quotes, curly quotes and unquoted property names — JSON requires straight double quotes around every string and key; “smart” quotes pasted from Word or Slack are named as such.
- Comments —
//and/* */are not part of JSON, even though some config files allow them. - Python literals —
True,FalseandNonefrom a Pythonprint()instead ofjson.dumps(). - Invisible characters — a non-breaking space or zero-width space is named rather than shown as a blank; a leading byte-order mark is simply ignored.
- Missing commas, mismatched brackets, line breaks inside strings, leading zeros,
NaNandundefined, and several top-level values pasted one after another.
Repair is a forgiving parser that rewrites the input as valid JSON and lists every change: it strips comments, removes trailing and doubled commas, adds missing commas and colons, converts single, curly and backtick quotes, quotes bare keys (including accented ones such as café), turns JSON5 numbers such as 0x1F, +5 and .5 into plain decimals, maps Python True/None and tuples, unwraps ObjectId("…"), JSONP and Markdown code fences, and closes brackets and strings in truncated JSON. Because a missing comma or a cut-off file can hide real data loss, check the result — the Undo button restores your original.
Big numbers, duplicate keys and why formatting is exact
Most online formatters run JSON.parse then JSON.stringify. That quietly changes your data: JavaScript numbers are 64-bit floats, so an ID like 9007199254740993 becomes 9007199254740992, and when a key appears twice only the last value survives. For database IDs, Twitter/X snowflake IDs or payment references that is a real bug.
This tool never converts your numbers. Its own parser keeps every number as the digits you wrote and every object as an ordered list of key–value pairs, so big integers, 1.0000000000000001, 1E400, duplicate keys and key order come through untouched in every feature. Sort keys is a stable sort, so two entries with the same key stay next to each other in their original order. The status line still warns you about big integers and duplicate keys, because the next program to read the file probably won’t be as careful.
| Feature | Big integers and duplicate keys |
|---|---|
| Format, Minify, Validate | Kept — the text is re-indented, not re-encoded |
| Sort keys, Tree, Search | Kept — number text and every duplicate are carried through |
| CSV, YAML, XML | Kept — duplicates become a, a (2) columns in CSV and repeated keys or elements in YAML and XML |
JSON to CSV, YAML and XML, and large files
JSON → CSV takes an array of objects (or the first array property of an object, as many APIs wrap results in {"data": [...]}) and builds one column per key across all rows, flattening nested objects into dot-named columns such as address.city. Choose a comma, a semicolon (what Excel expects in most of Europe) or a tab. Values starting with =, +, - or @ are prefixed with an apostrophe so spreadsheets can’t execute them as formulas, and the downloaded file starts with a UTF-8 byte-order mark so Excel shows £ and accents correctly.
JSON → YAML writes block-style YAML with two-space indentation and quotes any string a YAML parser would misread — yes, no, on, off, null, 007, dates and anything containing : or # — so the values come back exactly as they were. JSON → XML wraps the document in <root>, repeats an element for each array item, escapes & and <, and keeps keys that aren’t valid XML names in a key attribute.
Escape to string turns the input into a JSON string literal for embedding in another document; Unescape string reverses it, which is the fix for log lines full of \". To pass JSON through a URL or an HTTP header, encode it with Base64; for dummy text values in a mock payload, use the lorem ipsum generator.
Everything runs in your browser. Parsing and conversion happen in a background worker, with a progress bar and a Cancel button for big jobs, and the output view only draws the lines on screen. On a typical laptop a 6 MB file formats in well under a second while the page stays responsive; the time shown in the status line includes drawing the result. Checking as you type pauses above 1 MB — press Validate or Format instead. The limit is your device’s memory; files over 200 MB are refused.
Frequently asked questions
Is it safe to paste confidential JSON here?
Your JSON is processed by JavaScript on your own device and is never sent to us or stored. Like every page on this site, this one loads Cloudflare Web Analytics and Google AdSense; our code never passes your data to either. The only request involving your data is Fetch, which your browser makes directly to the address you type. For highly sensitive data, an offline formatter or a private window with ads blocked removes even that third-party code.
Why does my JSON fail with ‘trailing comma’ when it works in JavaScript?
JavaScript object literals allow a comma after the last item, but the JSON specification does not, and strict parsers reject it. Remove the comma before the closing bracket, or press Repair, which removes every trailing comma and tells you it has done so.
What is the difference between Format and Minify?
Format adds line breaks and indentation so people can read the structure. Minify removes all optional whitespace, producing the smallest possible file for sending over a network or storing. Both contain exactly the same data, and switching between them never alters values here.
Will sorting keys change my big numbers or duplicate keys?
No. Sorting uses this tool’s own lossless parser rather than JavaScript’s JSON.parse, so a 19-digit ID keeps every digit and duplicate keys are kept side by side in their original order. Other tools that parse your data — including many databases and JavaScript itself — may still round integers above 9,007,199,254,740,991, so storing large IDs as strings is the safest choice.
Can it handle JSON Lines or several objects at once?
Yes. If every non-empty line is a valid JSON value, the input is treated as JSON Lines (also called NDJSON). Validate reports the number of records, Minify outputs one compact record per line, and Format, the tree, search and the CSV, YAML and XML converters work on the records as one array. Several objects run together on one line are still an error; Repair can wrap them in an array.
How big a file can I format?
Files of tens of megabytes work, limited by your device’s memory. Parsing runs in a background worker with a progress bar and a Cancel button, and the output view only draws the lines you can see, so the page stays responsive: a 6 MB file formats in well under a second on a typical laptop. Checking as you type pauses above 1 MB, and files over 200 MB are refused.
What can Repair fix, and what can’t it?
Repair fixes comments, trailing, doubled and missing commas, missing colons, single, curly and backtick quotes, unquoted keys, JSON5 numbers, Python literals and tuples, NaN and undefined, JSONP and Markdown wrappers, and truncated JSON with unclosed strings or brackets. It cannot know what a cut-off file was meant to contain, so it closes what is open and lists the change. Always check the result, and use Undo to restore your original.