HomeFormattersCodeJSON Formatter/Beautifier

JSON Formatter/Beautifier

Code

Paste raw JSON and instantly beautify it with proper indentation, or minify it to save space. Runs entirely in your browser — nothing is uploaded anywhere.

What is a JSON?

A JSON Formatter takes raw JSON text — typically a minified API response, a single-line config export, or hand-typed data with inconsistent spacing — and reformats it with clean, consistent indentation so its structure is immediately readable. JSON itself doesn't care about whitespace; a formatter exists purely to make the nesting of objects and arrays visible to a human reader rather than a parser.

Most real-world JSON you encounter — from a browser's network tab, a curl response, or a deployed configuration file — is minified to save bandwidth, which collapses everything onto one line. The JSON Formatter reverses that, adding line breaks and indentation back in, or going the other direction with the minify option when you need the compact form again for production use.

How to use this JSON calculator

  1. Paste your raw JSON into the Raw JSON input box — replacing the example text shown by default.
  2. Choose your preferred Indent size (2 spaces, 4 spaces, or Tab) from the dropdown.
  3. Leave Minify instead of beautify off to get readable, indented output, or switch it on to get the compact single-line version.
  4. Review the formatted result, which updates instantly as you type or change options.
  5. Click the copy icon to copy the formatted JSON to your clipboard, then paste it wherever you need it.

Formula & Methodology

This tool uses the browser's built-in JSON engine rather than a hand-rolled parser, since JSON.parse/JSON.stringify are both fast and fully spec-compliant:

1. JSON.parse(rawInput) converts your text into an in-memory JavaScript value, throwing a descriptive error if the syntax is invalid.
2. For beautify mode: JSON.stringify(value, null, indent) re-serialises that value with the chosen indent (a number of spaces, or "\t" for a tab).
3. For minify mode: JSON.stringify(value) (no indent argument) re-serialises it with no extra whitespace at all.

Before (minified):
{"name":"thecalcu.com","calculators":134,"converters":37}

After (beautified, 2-space indent):
{   "name": "thecalcu.com",   "calculators": 134,   "converters": 37 }
Frequently Asked Questions
What does a JSON formatter do?
A JSON formatter takes raw, often unreadable JSON — minified API responses, single-line config exports, or hand-typed objects with inconsistent spacing — and reformats it with consistent indentation and line breaks. This makes nested objects and arrays easy to scan visually instead of reading them as one long string.
Why is raw JSON hard to read?
JSON returned by APIs is almost always minified to save bandwidth, which means every object and array is squeezed onto a single line with no spacing. Once you nest nest objects a few levels deep, a minified payload becomes nearly impossible to read without a formatter inserting line breaks and indentation.
What's the difference between minify and pretty-print?
Pretty-print (beautify) adds line breaks and indentation so humans can read the structure easily, while minify strips all unnecessary whitespace to produce the smallest possible file size for transmission over a network. Use pretty-print while debugging or reviewing data, and minify when you need to ship the JSON to production.
How do I format JSON with this tool?
Paste your raw JSON into the input box and it formats instantly using your chosen indent size. Switch on **Minify instead of beautify** if you want the compact, single-line version instead, and use the copy icon to copy the result.
Can this tool fix invalid JSON?
No — this tool formats syntactically valid JSON, it does not repair broken JSON. If your input has a syntax error (a missing comma, an unquoted key, a trailing comma), the result box shows the exact parse error instead of a guess, so you can locate and fix the problem in your source.
Is my data uploaded anywhere?
No. Formatting happens entirely in your browser using the built-in `JSON.parse`/`JSON.stringify` functions — your JSON is never sent to a server, logged, or stored, which matters if you're pasting in real API responses or configuration that might contain sensitive data.
Does this work offline?
Yes — once the page has loaded, formatting runs entirely client-side with no further network requests, so it continues to work even without an internet connection.
What indent size should I use?
2 spaces is the most common convention in modern JavaScript/JSON tooling and keeps deeply nested structures compact; 4 spaces is more readable for shallow structures but takes up more horizontal space. Use whichever matches your team's existing style guide or `.editorconfig` setting.
Can I format very large JSON files?
Yes, within reason — formatting runs synchronously in your browser, so extremely large payloads (tens of megabytes) may briefly freeze the page while processing. For typical API responses and config files, performance is instant.
Why does my JSON show an error even though it looks correct?
The most common causes are a trailing comma after the last item in an object or array, single quotes instead of double quotes around keys/strings, or an unquoted object key — all valid in JavaScript object literals but not valid in strict JSON. The error message includes the position where parsing failed to help you locate it.
What is JSON used for?
JSON (JavaScript Object Notation) is the standard format for exchanging structured data between web APIs, configuration files, and most modern application data storage. If you're working with other structured text formats, the [Text to Slug Converter](/text-to-slug-formatter/) and other thecalcu.com formatters cover related everyday text-processing needs.