JSON Formatter

Beautify and pretty-print JSON with configurable indentation.

Input218 chars
Output
paste JSON and click Format

Related Tools

Documentation

What is JSON Formatter?

JSON Formatter re-indents raw or minified JSON so its structure is readable at a glance — every key on its own line, nesting shown through indentation. It's the fastest way to make sense of a dense API response or config file.

How it works

The tool parses your input with JSON.parse(), which validates the syntax as a side effect, then serializes the result back with JSON.stringify(data, null, indent). If parsing fails, the raw error position is converted into a line and column so you know exactly where to look.

Features

  • 2-space, 4-space, or tab indentation
  • Alphabetical key sorting for diff-friendly output
  • Tree and raw syntax-highlighted views
  • Line/column error reporting
  • Copy, download as .json, or load a file directly

Example

Input: {"name":"ok","tags":["a","b"]}

Output (2-space indent):

{
  "name": "ok",
  "tags": [
    "a",
    "b"
  ]
}

Common errors

The most frequent JSON.parse failures: a trailing comma after the last item in an object or array, single-quoted strings instead of double quotes, unquoted object keys, and comments (JSON has no comment syntax). Each produces a specific line/column in the error bar.

Best practices

Keep production payloads minified (smaller over the wire) and only format when a human needs to read them. Sort keys before committing generated fixtures to version control, so diffs show real changes instead of reordering noise.

Spec

RFC 8259 — The JSON Data Interchange Format

Frequently Asked Questions

What is a JSON formatter?▾

A JSON formatter takes compact or minified JSON text and re-indents it with consistent spacing and line breaks — also called pretty-printing. It doesn't change the data, only its presentation.

How do I format JSON?▾

Paste JSON into the input panel, pick an indent style (2 spaces, 4 spaces, or tab), then click Format (or press Cmd/Ctrl+Enter). The formatted result appears in the output panel with syntax highlighting.

Why does Format say my JSON is invalid?▾

The formatter runs your input through the browser's native JSON.parse, which is strict — no trailing commas, no comments, and keys must be double-quoted. The error message includes the line and column where parsing failed.

What does "Sort Keys" do?▾

It recursively sorts every object's keys alphabetically before formatting. Useful for diffing two JSON documents that have the same data but different key ordering.

Does this tool send my JSON anywhere?▾

No. Formatting happens entirely with JSON.parse/JSON.stringify in your browser. Nothing is uploaded — you can disconnect from the internet and the tool keeps working.

Is my input saved anywhere?▾

Only in your own browser's localStorage, so it's still there if you navigate away and come back. It never leaves your device.

What's the difference between Format and Minify?▾

Format adds indentation and line breaks for readability. Minify strips all non-essential whitespace to produce the smallest valid JSON — useful before sending a payload over the network.

Is there a file size limit?▾

The tool refuses input over 5 MB to keep the browser responsive, since JSON.parse holds the entire parsed structure in memory. Everything under that runs in milliseconds on any modern device.

Can I upload a .json file directly?▾

Yes — click Load File to read a file from disk via the browser's FileReader API. Like everything else here, the file never leaves your machine.