JSON Formatter & Beautifier

Paste minified or messy JSON and get it pretty printed, minified or sorted. It runs in your browser, and only the whitespace changes.

Ctrl+Enter also works. Your JSON is processed in your browser and never sent to a server.

A Formatter That Does Not Touch Your Data

The quick way to pretty print JSON is JSON.stringify(JSON.parse(text), null, 2), and most online formatters do exactly that. It reads the text into JavaScript values and writes those values back out, which is not the same thing as re-indenting your text. Here is what that round trip changes:

You wroteAfter parse and stringifyWhy it matters
1234567890123456789012345678901234567000Past 2^53, a JavaScript number cannot hold every integer, so an order or account id is rounded.
49.9049.9The trailing zero of a price disappears.
1E2100Exponent notation is rewritten.
"\u00e9""é"Escapes are decoded, so the bytes change.
{"a": 1, "a": 2}{"a": 2}A repeated key is silently dropped.

This formatter reads the structure itself and prints every number, string and key back character for character, so the left column is what you get. Validity is still decided by your browser's own JSON parser, which implements the standard, so a document is never called invalid unless it really is.

What You Can Do With It

Pretty print an API response

Paste a one-line response from curl or the network tab and read it as a tree of indented objects. Choose 2 spaces, 4 spaces or tabs.

Minify a payload

Strip every optional space before you paste JSON into an environment variable, a test fixture or a request body. The size before and after is shown.

Prepare a text diff

Sort keys on both files before a line diff or a code review, so key order no longer shows up as a change.

Find the broken comma

Invalid JSON is not formatted. You get the line and column of the first error, a click that selects it, and the guide that explains the fix.

Formatting or Validating?

Both tools check that your JSON is valid. This page is for shaping it: indentation, minifying and key order. If you only need to know whether a document parses and where it breaks, the JSON Validator is the shorter path, and to explore a large document and copy the path to a value, use the JSON Viewer. To see what changed between two versions, the JSON Compare tool lists every added, removed and changed value. When either one finds an error, the JSON error guides show the wrong and right version side by side, from trailing commas to unexpected token.

Frequently Asked Questions

Does formatting change my JSON data?
No. This formatter only changes whitespace. Every number, string and key is printed back exactly as you wrote it, including very large integers, trailing zeros, exponents, escape sequences and repeated keys. Many formatters parse the JSON into JavaScript values and print those, which can round large numbers and drop duplicate keys.
Is my JSON sent to a server?
No. Formatting runs in your browser with JavaScript. The JSON you paste is not uploaded, logged or stored, which makes the tool safe for API responses, tokens in test payloads and customer data.
What is the difference between beautify and minify?
Beautify adds line breaks and indentation so the structure is readable. Minify removes every optional space and line break so the document is as small as possible, which is what you want for a payload, a config value or a fixture. Both describe exactly the same data.
Should I indent JSON with 2 spaces, 4 spaces or tabs?
2 spaces is the most common choice in JavaScript projects and is what JSON.stringify(data, null, 2) produces. 4 spaces is common in Python projects (json.dumps with indent=4). Tabs let each reader choose their own width. Pick whatever your repository already uses so diffs stay small.
What does sort keys do?
It orders the keys of every object alphabetically, at every level, without touching the order of array items. Two JSON files with the same data then format identically, which makes them easy to compare in a diff. Sorting is by character code, so uppercase keys come before lowercase ones.
Why will my JSON not format?
Only valid JSON can be formatted. The formatter tells you the line and column of the first error and links to a guide for it. The usual causes are a trailing comma, single quotes, keys without quotes, a missing comma, comments, or JavaScript values such as undefined or NaN that JSON does not have.
Can it format JSON with comments (JSONC or JSON5)?
No. Comments, trailing commas and unquoted keys are not JSON, even though some editors and config loaders accept them. The formatter reports them as errors rather than guessing what you meant, so the output is always JSON that any parser will accept.
Is there a size limit?
No fixed limit, since nothing is uploaded. Files of several megabytes format in well under a second on a normal laptop. Extremely deep nesting, more than 1,000 levels, is refused with an explanation rather than risking the browser tab.

Related Tools