TextyConverterbeta
⌘K

JSON Formatter

Format and pretty-print JSON with adjustable indentation. Validates as you type. Free, browser-only, no signup.

Indent
0 characters
0 characters

About JSON Formatter

The JSON formatter (also called a JSON pretty-printer or beautifier) takes a JSON document — whether minified, broken across lines inconsistently, or hand-edited — and re-emits it with consistent indentation, one key per line, and predictable whitespace. The result is the same data, but easier for a human to read and review in a diff. Parsing is performed in your browser using the native JSON.parse API, so the document never leaves your device.

When to use it

  • Inspecting an API response copied from the browser network tab or curl
  • Reviewing config files (package.json, tsconfig.json, .eslintrc) in a code review
  • Diffing two JSON payloads after formatting both with the same indent
  • Preparing a JSON document to paste into documentation or a bug report
  • Validating that a hand-edited JSON file is still syntactically correct
  • Normalizing key order across files before committing to source control

How it works

The input is parsed with JSON.parse, which builds an in-memory JavaScript value tree. That tree is then re-emitted via JSON.stringify with the chosen indent (2 spaces, 4 spaces, or a tab character). If 'sort keys' is enabled, every object's keys are sorted alphabetically before serialization — recursively, all the way down. Because the document is fully reparsed, the formatter also acts as a validator: any syntax error is surfaced with a line and column number so you can jump straight to the offending character.

Examples

Minified input → 2-space indent
{"name":"Ada","skills":["math","logic"],"active":true}
{
  "name": "Ada",
  "skills": [
    "math",
    "logic"
  ],
  "active": true
}
Array of objects keeps original order
[{"id":2,"x":1},{"id":1,"x":2}]
[
  {
    "id": 2,
    "x": 1
  },
  {
    "id": 1,
    "x": 2
  }
]
With 'sort keys' enabled
{ "b": 1, "a": 2, "c": { "y": 1, "x": 2 } }
{
  "a": 2,
  "b": 1,
  "c": {
    "x": 2,
    "y": 1
  }
}

Frequently asked questions

Is my JSON sent to a server?
No. Parsing and formatting both run entirely in your browser via the built-in JSON.parse and JSON.stringify APIs. The document never leaves your device, which makes the formatter safe to use on internal API responses, secrets-bearing configs, and other sensitive data.
What indent should I use?
Two spaces is the de-facto standard for JSON on the web and in most style guides (Prettier, JSON Schema docs, GitHub's own conventions). Four spaces is common in Python-flavored codebases. Tabs are rare in JSON but supported if your team prefers them.
Does this also validate the JSON?
Yes — the formatter parses the input fully, so any structural error (missing comma, unquoted key, trailing comma, mismatched bracket) is reported with a line and column number. If you only want a yes/no answer, use the dedicated JSON validator.
Why does it reject trailing commas and comments?
Strict JSON, defined in RFC 8259, does not allow trailing commas or comments. Variants that do (JSONC, JSON5) are not handled by JSON.parse. If you need to format those, strip the extras first or use a dedicated JSONC/JSON5 tool.
Is there a maximum size?
There is no hard limit, but in-browser parsing is memory-bound. Documents up to a few hundred megabytes generally work; multi-gigabyte files should be processed with a streaming parser at the command line instead.
Does formatting change the data?
No. The output represents the same JSON value as the input — only whitespace and (optionally) key order change. Numbers, strings, booleans, null, arrays, and objects round-trip exactly. One caveat: large integers beyond 2^53 lose precision because JavaScript stores all numbers as IEEE-754 doubles.

Related tools