CalcFacts
Developer calculator

JSON Formatter

Format, validate, and minify JSON with error locations.

Interactive calculator
spaces

Output

Valid JSON

Yes

Indent: 2 spaces

Size

158 chars

Nesting depth

3

{
  "name": "Alice",
  "tags": [
    "admin",
    "editor"
  ],
  "address": {
    "city": "New York",
    "zip": "10001"
  },
  "active": true,
  "age": 30
}

Statistics

Object keys
7
Arrays
1
Primitive values
7
Max depth
3

Formatting runs entirely in your browser — nothing is uploaded. Syntax errors show the exact line and column so you can fix them quickly. Pretty-printing is for reading; minifying shrinks the file for shipping in requests or deployments.

How to use the json formatter

The JSON formatter does three jobs in one place: it validates that your JSON is syntactically correct, pretty-prints it so a human can read it, and minifies it so a machine can ship it. Paste any JSON — an API response, a config file, a database export — and get clean, readable output along with statistics about what is inside.

Every developer who works with APIs runs into the same situation: an endpoint returns a single unreadable line of JSON, or a config file fails to load and you have no idea which character broke it. This tool solves both problems instantly, and it runs entirely in your browser, so nothing you paste is ever sent to a server.

Validating JSON and finding syntax errors

JSON is strict: keys must be double-quoted, there are no trailing commas, and no comments are allowed. One missing quote or an extra comma deep in a nested object makes the whole document invalid, and the default browser error message is usually unhelpful.

This formatter reports the exact line and column of the first syntax error, so you can jump straight to the broken character instead of scanning the whole file. Common mistakes it catches include single-quoted strings, trailing commas after the last array element, JavaScript-style comments, unquoted keys, and numbers written with a leading plus sign.

Pretty-printing for humans

Pretty-printing inserts line breaks and indentation so nested structures become visually obvious. You can choose the indent width from one to eight spaces — two is the default and the most common convention in configuration files. Once formatted, you can copy the result or download it as a .json file.

Reading formatted JSON is genuinely faster: you can see at a glance which keys are siblings, where an array starts and ends, and how deeply a field is nested. This matters when you are debugging an API response or reviewing a config change before committing it.

Minifying for machines

Minifying removes all unnecessary whitespace and puts the JSON back on a single line. This is what you want when JSON travels: in an HTTP request body, in a build artifact, or embedded in a script tag. Smaller payloads parse marginally faster and use less bandwidth — and for files that will never be read by human eyes, there is no reason to ship the extra spaces.

The tool shows the output size before and after, so you can see exactly how much space minification saved. In practice, minifying typically shrinks pretty-printed JSON by 20–40%, depending on how deeply nested it is.

Understanding the statistics

Alongside the output, the formatter counts object keys, arrays, primitive values, and the maximum nesting depth. These numbers are more useful than they first appear: a depth of 8 might be normal for a schema but suspicious for a settings file, and a key count that jumps between two API versions can reveal a breaking change. The stats update live as you edit, which makes this a quick way to get a structural sense of an unfamiliar JSON document.

Privacy

Nothing leaves your browser. The JSON you paste is parsed with the native JavaScript engine on your own machine, and the output stays there until you copy or download it. That makes the tool safe for API keys that leaked into a response, private customer data, internal configuration, or anything else you would not paste into a public website.

Frequently asked questions

Why does my JSON fail to parse?

The most common causes are single-quoted strings (JSON requires double quotes), trailing commas after the last element, comments, and unquoted keys. This formatter reports the exact line and column of the first error so you can fix it immediately.

What is the difference between pretty-printed and minified JSON?

Pretty-printed JSON has line breaks and indentation so humans can read it — use it while debugging or editing. Minified JSON removes all unnecessary whitespace for the smallest possible size — use it when sending data over the network or shipping build artifacts.

Is there a size limit to what I can format?

There is no hard limit from the tool itself, but very large files (many megabytes) are constrained by your browser's memory. For typical API responses and config files the formatter is effectively instant.

Does this tool upload my JSON anywhere?

No. Parsing and formatting happen entirely in your browser using the native JSON engine. Nothing is transmitted, logged, or stored, so the tool is safe for sensitive or proprietary data.

What do the statistics mean?

The stats count object keys, arrays, primitive values, and the maximum nesting depth of your document. They give you a quick structural summary — for example, spotting unexpectedly deep nesting or comparing the shape of two API responses.

Related calculators

View all

Why use CalcFacts?

  • Every calculation runs in your browser — nothing is uploaded.
  • No signup, no paywall, no email required.
  • Clear formulas and breakdowns you can verify yourself.
  • Built for speed: results update as you type.