JSON Formatter
/json-formatter/
Related tools
Related posts
Comments
About this tool
Why developers use a JSON formatter
JSON is everywhere in software work: web API responses, configuration files, logs and database exports. JSON sent by servers often arrives on a single line with no whitespace to save bytes, and once objects nest a few levels deep it becomes hard to follow by eye. A formatter expands that JSON into indented lines so the structure is readable at a glance, and it can also compress hand-written JSON back onto one line.
Read moreShow less
JSON was popularized in the early 2000s by Douglas Crockford, who derived it from JavaScript object notation; today its grammar is defined by IETF RFC 8259 and ECMA-404. The rules are short and strict, so when people edit JSON by hand a single comma or quote can make the whole file unreadable. That is why this tool doubles as a syntax checker.
How the JSON formatter rewrites text with JSON.parse and JSON.stringify
Pasted text is first parsed with the browser's built-in JSON.parse and, if that succeeds, written back with JSON.stringify. Beautify breaks it into lines with 2 spaces, 4 spaces or a tab per level, and Minify removes all spaces and line breaks. A small example containing two users is 228 characters with 2-space indentation, 111 characters minified, less than half, and 318 characters with 4 spaces. A tab uses a single character per level, so the same example is 183 characters.
Because the text is read into values and written out again, some details change. Unicode escapes like \uD55C\uAE00 become the actual characters (here the Korean word 한글), 1.0 becomes 1 and 1e3 becomes 1000. If a key appears twice, only the last value survives. Due to JavaScript object rules, keys made only of digits, such as "10" and "2", move to the front in ascending numeric order, while other keys keep the order you typed.
If the syntax is wrong, you get an error message with a line and column instead of a result. The position is where the parser noticed the problem, so it can point one character past the actual mistake. With a trailing comma, as in {"a":1,}, Chrome points at line 1, column 8, the } after the comma, and says a double-quoted property name was expected. The wording of the message itself varies by browser.
Using a JSON formatter in everyday work
For backend and frontend developers the most common use is pasting an API response from browser developer tools or curl to inspect its fields. Logs where non-ASCII text was escaped, as Python's json.dumps does by default (turning 한 into \ud55c, for example), also become readable characters once formatted here.
It also helps when you have edited a configuration file by hand and want to check the syntax before deploying. If a result appears, the JSON is standard-compliant; if an error appears, start at that line. JSON Lines files, with one JSON value per line as in many logs, are not a single JSON document, so they fail on line 2; check them one line at a time.
Non-developers such as product managers or data analysts find Beautify useful for skimming the entries in a JSON export. Minify, on the other hand, is for putting JSON into an environment variable or a one-line setting, or for trimming transfer size a little.
The strict rules of standard JSON and the formatter's limits
Standard JSON does not allow comments, trailing commas, single-quoted strings, unquoted keys, NaN or Infinity, or numbers with a leading zero such as 01. Files with comments, like tsconfig.json or VS Code settings, use an extended format called JSONC and will show an error here. Conversely, a lone non-object value such as "text" or 123 is valid JSON under RFC 8259 and passes as is.
Numbers are read as JavaScript 64-bit floating point, so integers larger than 9007199254740991 (2 to the 53rd power minus 1) cannot be held exactly. Entering 9007199254740993 actually comes out as 9007199254740992. When handling long values such as social media post IDs or order numbers, compare the last digits of the result with the original, and where possible have the server send them as strings.
Input and output are processed only inside this browser and are not sent to a server. Your input and options are kept in this browser so you can continue later, and the last 5 successfully formatted entries appear under Recent below the tool. If you have handled JSON containing production access tokens or personal data, clear the input with Reset and empty the history with Clear afterwards, and keep in mind that screen sharing and screenshots can leak it too.
Popular tools
FAQ
Can I use it just to validate JSON?
Yes. If a result appears when you paste, the JSON is standard-compliant; if not, you see an error message with the line and column. The position sometimes points one character past the real mistake, so look just before it as well.
Can it format JSON with comments?
No. Standard JSON has no comments, so // or /* */ cause an error. Remove the comments from JSONC files like tsconfig.json first, or use YAML for configuration that needs comments.
What does an Unexpected token error mean?
The parser hit a character that cannot appear at that position. Common causes are single-quoted strings, unquoted keys, values like NaN, and extra text before or after the JSON.
Why did the last digits of a large number change?
Numbers are read as JavaScript numbers, so integers above 9007199254740991 lose precision; 9007199254740993 comes out as 9007199254740992. IDs that must stay exact are safer handled as strings.
Does it convert \uXXXX escapes into readable characters?
Yes. Unicode escapes are turned into the actual characters while parsing, so the formatted output shows the real text. The same happens when you minify.
Is my JSON saved or sent anywhere?
It is not sent to a server; it is processed in the browser with JSON.parse and JSON.stringify only. Your input, options and the last 5 entries are kept in this browser's localStorage for next time, and Reset and Clear remove them.