What does a JSON formatter do?
A JSON formatter reads JSON text, checks it against the grammar, and writes it back out with consistent indentation and line breaks. The data stays the same; only the whitespace changes, so a 40 KB API response on one line becomes something you can scan and debug.
People also call this a JSON beautifier or a tool to pretty print JSON. The terms mean the same job. Most tools add a JSON validator on top, because formatting is impossible until the text parses. That is why search results mix "JSON formatter and validator" and "JSON validator and formatter": it is one tool with two outputs.
This page adds four things most online tools skip. It keeps every number and string exactly as written, it reports errors with a caret and a suggested fix, it shows a lazy tree view that stays fast on big files, and it flags duplicate keys and numbers that JavaScript would round.
How does the JSON validator find errors?
The validator walks the text one character at a time and stops at the first character that breaks the JSON grammar in RFC 8259. It reports the line and column itself, so the result is the same in every browser, and it explains the usual cause.
Browser error messages differ. Chrome, Firefox and Safari each word JSON.parse failures their own way, and some only give a character offset. Counting to character 4,812 by hand is no fun, so this page does it for you and shows the broken line with a ^ under the problem.
| What you see | Why it's invalid | Fix |
|---|---|---|
[1, 2, 3,] | Trailing commas are not allowed | Delete the last comma |
{'name': 'Ada'} | Single quotes are JavaScript, not JSON | Use double quotes for keys and strings |
{name: "Ada"} | Property names must be quoted | Write "name" |
// comment | JSON has no comment syntax | Remove the comment, or move it into a field |
"a": 1 "b": 2 | Missing comma between members | Add a comma after 1 |
undefined, NaN, True | Not JSON values | Use null, a number, or lowercase true |
007 | Leading zeros are not allowed | Write 7, or keep codes as strings |
| A real line break inside quotes | Control characters must be escaped | Write \n instead |
How do I use the JSON viewer tree?
Switch the output to Tree to use it as a JSON viewer. Objects show their key count and arrays show their length, so you can see the shape of a response before opening anything.
- Expand and collapse: click a row, or use Expand all and Collapse all. Expand all stops after a few thousand nodes so a huge file can't lock the tab.
- Copy a path: click any key or array index to copy its JSONPath-style path, like
$.items[3].nameor$["free over"]for keys with spaces. Paste it into code, a jq filter or a test. - Show types: tick it to label every value as string, number, boolean, null, object or array. Handy when an API returns
"42"where you expected42. - Big arrays: children load 200 at a time with a Show next button, so a 100,000-item array opens instantly.
The tree shows keys in their original order, even if you sort keys in the text output. That makes it a faithful JSON object formatter view of what the server actually sent.
JSON beautifier or JSON minify: which do you need?
Beautify when a person will read the JSON; minify when a program will. Minified JSON drops every space and line break outside strings, which makes payloads and config values smaller but unreadable.
| Pretty print (Format) | Minify | |
|---|---|---|
| Best for | Reading, debugging, code review, docs | API payloads, storage, environment variables |
| Whitespace | Indents with 2 spaces, 4 spaces or tabs | None outside strings |
| Size | Larger | Smallest possible text |
| Data changed? | No | No |
In code, JSON.stringify(value, null, 2) pretty prints and JSON.stringify(value) minifies. Both work on a parsed value, which is where precision can slip (see the next section). The Format and Minify buttons here work on the text instead.
const data = JSON.parse(text);
JSON.stringify(data, null, 2); // pretty print, 2-space indent
JSON.stringify(data, null, "\t"); // tab indent
JSON.stringify(data); // minifySort keys A–Z reorders object keys at every level. It is useful before you compare two responses, since key order often changes between runs. Sort both, then paste them into the JSON diff checker to see only the real changes.
Why do big numbers change in other JSON formatters?
Most online tools parse your text into JavaScript numbers, and JavaScript numbers are 64-bit floats. Integers above 2^53 − 1 (9,007,199,254,740,991) can't all be stored exactly, so 9007199254740993 comes back as 9007199254740992 without any warning.
JSON.parse. Larger ones are rounded to the nearest value a double can hold.This tool never converts your numbers. Its parser keeps each number as the exact text you pasted, so formatting and minifying are lossless. It also flags every number that other JavaScript code would round, with its line and column.
How do I escape or unescape a JSON string?
Press Escape string to turn everything in the input into one JSON string, with quotes and backslashes escaped. Press Unescape string to reverse it. If the unescaped text is itself valid JSON, the tool formats it for you.
You need this when JSON is stored inside JSON: log lines, message queues, a body field in a webhook, or a config value in a database. It looks like "{\"id\":1}". Unescape it, press Use as input, then format the inner document.
Escaping is not encoding. If a system wants the JSON as Base64 (common in JWTs, data URLs and some queues), use the Base64 encoder and decoder after you format it. If a field holds an epoch time like 1790000000, the Unix timestamp converter turns it into a date.
Online JSON formatter or a Chrome extension JSON formatter?
Use an online JSON formatter for text you paste or files you open. Use a Chrome extension JSON formatter if you mostly read JSON that APIs return in the browser tab, because it formats the page as it loads with no copy and paste.
| Need | This page | Extension |
|---|---|---|
| Format pasted text or a file | Yes | Usually no |
| Auto-format a JSON URL you open | No | Yes |
| Error line, column and fix | Yes | Varies; many just show raw text |
| Install or permissions | None | Needs access to the pages it formats |
| Works on a locked-down work laptop | Yes, if the site is allowed | Only if extensions are allowed |
If you want the JSON formatter extension Chrome users install most, start with JSON Formatter, an open-source extension that formats JSON pages in place. Our JSON formatter Chrome extension guide compares the options and the permissions each one asks for. More developer picks are in developer tools.
One job this page doesn't do is convert data. A CSV to JSON formatter needs a converter first; paste its output here to check and tidy it.
Is it safe to paste JSON into an online JSON formatter?
It is safe here, because nothing is sent anywhere: the page has no server side for your data. Be careful with any other JSON formatter online: some save your input to a shareable link or process it on a server.
API responses often hold access tokens, emails or customer records. Before you paste them into any site, check its privacy note. You can confirm this page's behaviour yourself: open DevTools, go to the Network tab and press Format. No request is made.
- Files up to 50 MB
- Files over 1 MB stay in memory rather than in the text box, which keeps typing and scrolling smooth.
- Output preview
- Syntax colours switch off above about 250 KB, and the preview shows the first 1 MB. Copy and Download always include the full result.
- Nesting limit
- The parser stops at 1,000 levels deep. Real data rarely goes past 20.
- Byte order marks
- A leading BOM is ignored and reported, as RFC 8259 allows.