How to use the JSON Formatter — step by step
JSON is a way of writing structured data as text: names and values inside curly braces, lists inside square brackets, and every piece of text in double quotes. The JSON Formatter takes a block of that text and returns it in one of two layouts, so it is either easy to read or as short as possible. When the page opens, the box already holds a sample, {"name": "WhiteUI", "tools": ["EMI Calculator", "SIP Calculator"], "free": true, "tools_count": 2}, which is 98 characters long. The five steps below take you from there to a formatted result you can copy.
At a glance
Step 1: paste your JSON
Click into the box on the left, clear the sample if you do not need it, and paste your own JSON. It can come from anywhere: an API response, a settings file, or a message from a colleague. Nothing is sent anywhere, because everything runs in your browser. Paste the whole block: a missing closing brace is the most common reason for an error.
Step 2: check that it is valid
As soon as you paste, the result panel tells you whether the text is real JSON. For the sample it reads “Valid JSON · 4 top-level keys · Mode: Pretty”, and the big line reads “120 characters”. The four keys are name, tools, free and tools_count. If the text is not valid JSON, the big line reads “Invalid JSON” instead, and the line below it shows the parser’s error, which names the exact position of the problem, so you know where to look.
Step 3: pick Pretty or Compact
Two buttons sit under the result: Pretty and Compact. Pretty spreads the JSON across lines with two spaces of indent per level, so the sample becomes 9 lines and 120 characters, and you can read the structure at a glance. Compact squeezes it onto one line with no extra spaces, so the same sample becomes 90 characters, and it fits where space is tight, such as a single-line settings field. Both are the same data: the keys, the values and their order do not change, only the whitespace does. Pick Pretty when a person will read it, and Compact when a program will store it.
Step 4: read the counts
Under the big line, the tool prints the numbers that describe the change. For the sample in Pretty mode it reads “Original: 98 characters · Formatted: 120 characters”, which tells you the formatting added 22 characters of spaces and line breaks. Switch to Compact and the same line reads “Original: 98 characters · Formatted: 90 characters”, because Compact removed 8 characters of spaces from the original. Those counts are a quick check that nothing was lost.
Step 5: copy or download the result
The formatted JSON sits in a box on the right. Press “Copy JSON” to put it on the clipboard, then paste it wherever it needs to go: a code editor, a document, or a message. Press “Download .json” to save it as a file called formatted.json instead. The whole job, from pasting to copying, takes under a minute.
Worked example
Try a second input, an order record: {"order": 4517, "items": [{"name": "Notebook", "price": 120}, {"name": "Pen", "price": 45}], "paid": true}. It is 106 characters as pasted. In Pretty mode it becomes 162 characters across 14 lines, because the two items each take three lines, and the prices, 120 and 45, sit six spaces in. In Compact mode it becomes 94 characters on one line. The data is identical in both.
The common mistake
People paste JSON that uses single quotes, such as {"name": "x"} written with ’ instead of “, and the tool reports “Invalid JSON”. JSON only accepts double quotes around keys and text, so a single-quoted version fails at position 1, the very first character. Replace the single quotes with double quotes and paste again. A trailing comma, such as {"a": 1,}, fails the same way at position 8: remove the comma before the closing brace.
Frequently asked questions
What does the JSON Formatter show when it opens?
The sample already in the box, formatted in Pretty mode: 120 characters across 9 lines, with 4 top-level keys: name, tools, free and tools_count.
What is the difference between Pretty and Compact?
Pretty spreads the JSON across lines with 2 spaces of indent per level, so the sample is 120 characters; Compact puts it on one line with no extra spaces, so the same sample is 90 characters. The data is identical in both.
How do I copy the formatted result?
Press the Copy JSON button under the output box, or press Download .json to save it as formatted.json.
Why does it say my JSON is invalid?
Usually a single quote instead of a double quote, a trailing comma, or a missing closing brace. The error message names the exact position, so fix that spot and paste again.
More guides on the JSON Formatter
- JSON Formatter explained with worked examples
- JSON Formatter formula — how it actually works
- JSON Formatter for beginners — start here
- Common mistakes people make with the JSON Formatter
- JSON Formatter vs doing it by hand — which is faster?
- JSON Formatter — The Complete Guide
- How to get an accurate result from the JSON Formatter
- JSON Formatter for students — with examples
- JSON Formatter for homeowners and DIYers
Try the JSON Formatter — free, in your browser.