Toolsel

JSON Formatter

Runs in your browser

Format, validate and minify JSON with precise error locations.

Input

Output

CtrlEnterFormatCtrlShiftMMinifyCtrlShiftCCopy outputEscClear

What is a JSON Formatter?

A JSON formatter takes JSON that is hard to read — minified into one line, or inconsistently indented — and re-prints it with predictable indentation and line breaks. The same tool validates the input along the way, because JSON can only be re-printed if it can first be parsed.

In practice that second job is the one that matters most. API responses, config files and log lines fail for small reasons: a trailing comma, a single quote where a double quote belongs, an unescaped newline inside a string. A formatter that reports the line and column of the failure turns a vague "invalid JSON" into a one-second fix.

How to use it

  1. Paste your JSON into the input panel, or drop a .json file onto it.
  2. Choose an indentation width — 2 spaces is the common default, 4 is typical in Java and .NET codebases, and Tab suits Go projects.
  3. Press Format to pretty-print, or Minify to strip every optional space and newline.
  4. If the input is invalid, the error banner names the line and column where parsing stopped. Fix that spot and the output updates.
  5. Use Copy to put the result on your clipboard, or Download to save it as a .json file.

Example

Formatting a minified response

Input
{"id":42,"name":"Ada Lovelace","tags":["math","computing"],"active":true}
Output
{
  "id": 42,
  "name": "Ada Lovelace",
  "tags": [
    "math",
    "computing"
  ],
  "active": true
}

Frequently asked questions

Is my JSON sent to a server?
No. Parsing and formatting happen in your browser using the built-in JSON engine. Nothing is transmitted, logged or stored, which means it is safe to paste API responses that contain internal data.
Why does my JSON fail to parse when it looks correct?
The three usual causes are a trailing comma after the last item in an object or array, single quotes instead of double quotes around keys or strings, and comments. All three are valid JavaScript but none are valid JSON. JSON also requires keys to be quoted strings.
What is the difference between formatting and minifying?
Both produce semantically identical JSON. Formatting adds indentation and newlines so a human can read it. Minifying removes every byte that is not required, which is what you want before sending JSON over the network or storing it in a column.
Does formatting change the order of my keys?
No. JSON objects have no defined ordering in the specification, but this tool preserves the order the keys appeared in your input, so a formatted file still diffs cleanly against the original.
Can it handle very large files?
Files up to a few megabytes format instantly. Beyond roughly 10 MB the browser's own JSON parser becomes the bottleneck and the tab may pause for a moment while it works, since parsing is a single synchronous operation.