JSON Formatter

Beautify, validate and minify JSON with precise error locations.

Runs in your browser Instant No sign-up
Indent
JSON input
Formatted

Paste, type or drop a file — output appears as you type.

Waiting for input
Processed locally · nothing is uploadedProcessed locally

How to use the JSON formatter

  1. Paste, drop or open your JSON in the left pane. The output updates as you type — there is no button to press.
  2. Indent: 2 spaces (the most common convention in JavaScript projects), 4 spaces, tabs, or Minify to remove all whitespace.
  3. Turn on Sort keys to order object keys alphabetically at every level.
  4. Copy or Download the result. Share copies a link that stores your input in the URL fragment (the part after #), which browsers never send to a server.

Error messages that tell you what to fix

Built-in JSON error messages differ between browsers and often leave out the position. This formatter reports the exact line and column with a plain-English hint, and highlights the line in the editor:

Input Message
{"a": 1,} Trailing comma is not allowed before }
{'a': 1} Strings must use double quotes, not single quotes
{a: 1} Property names must be wrapped in double quotes
{"ok": True} ‘True’ is not valid JSON — use true
{"a": 1 "b": 2} Missing comma between properties

Click Jump to error to put the cursor on the problem. If the input came from a config file with comments or from an LLM response, Fix with JSON Repair opens it in JSON Repair with one click.

Details other formatters get wrong

  • Big integers stay exact. 9007199254740993 is printed as-is instead of being rounded to 9007199254740992.
  • Numbers are printed exactly as written. 98.50 and 1E5 are not rewritten as 98.5 and 100000, which matters for test fixtures and signed payloads.
  • Duplicate keys are flagged. {"id": 1, "id": 2} is technically parseable, but most parsers keep only the last value. You get a warning with the line number.
  • Byte order marks are handled. Files saved by some Windows editors start with an invisible BOM that breaks naive parsers; it is ignored here.

Formatter, Viewer or Diff?

The formatter is the fastest way to validate a document and get consistent indentation you can paste back into code. For other jobs, a neighboring tool fits better:

  • To explore a large or deeply nested payload, open it in the JSON Viewer. It shows a collapsible tree, searches keys and values, and copies the JSONPath of any node.
  • To see what changed between two versions of a response or config file, use JSON Diff. It ignores key order and lists each change by path.
  • To pull specific values out of a document, query it with the JSONPath Tester.

Working with a long file? The Full screen button in the toolbar gives both panes the whole window; press Esc to leave it.

Pretty-printing JSON in code

When you need the same result in a script:

// JavaScript / Node.js
JSON.stringify(JSON.parse(text), null, 2);
# jq
jq . data.json      # pretty-print
jq -c . data.json   # minify
jq -S . data.json   # sort keys
# Python
import json
print(json.dumps(json.loads(text), indent=2, sort_keys=True))

Each of these re-serializes numbers. JSON.parse rounds integers above 2^53, Python keeps integers exact but prints 98.50 as 98.5, and jq versions before 1.7 also round large integers. This formatter prints every number exactly as it appears in the input.

Frequently asked questions

Is my JSON sent to a server?

No. Parsing and formatting run in your browser tab, and nothing is uploaded. Once the page has loaded, the formatter keeps working even if you go offline.

Why does this formatter keep 9007199254740993 while others change it?

Many online formatters rely on JSON.parse, which stores every number as a 64-bit float and silently rounds integers above 2^53. This tool uses its own parser that keeps the original number text, so IDs, snowflakes and 64-bit database keys stay exact.

What is the difference between formatting and validating?

Validation checks that the text follows the JSON grammar (RFC 8259). Formatting re-prints valid JSON with consistent indentation. This tool does both at once: if the input is invalid, you get the exact line and column instead of formatted output.

Can it handle large files?

Yes. A 1 MB document formats in a fraction of a second, and a 7 MB file takes about a second on a recent laptop. Drag a .json file onto the input pane or use the open-file button; files up to 20 MB are accepted.

Does sorting keys change my data?

No. JSON objects are unordered by specification, so sorting keys alphabetically produces an equivalent document. It is useful for diffing two payloads or keeping config files stable in version control.

Last updated