JSON Formatter & Validator

Processed locally · Never leaves your browser

Beautify, minify, and validate JSON instantly. Live error detection with precise position info. Runs entirely in your browser.

Indent
Input JSON
Paste or type JSON
Output

JSON Quick Reference

Object
{ "key": "value" }
Array
["one", "two", 3]
String
"double quotes only"
Number
42, 3.14, -1, 1e5
Boolean
true / false
Null
null
Runs entirely in your browser — nothing is uploaded
Runs entirely in your browser. No uploads. Your files stay private.

What Is a JSON Formatter?

JSON (JavaScript Object Notation) is the data format that ate the world - originally specified by Douglas Crockford in 2001 and now described by RFC 8259 / ECMA-404. It is the wire format for almost every REST API, the on-disk format for package.json, tsconfig.json, .vscode/settings.json, and a thousand other config files. A formatter takes a compact or malformed-looking JSON document and re-emits it with consistent indentation so a human can actually read it.
This formatter is a thin wrapper around two native JavaScript built-ins: JSON.parse and JSON.stringify. JSON.parse runs the same parser the V8 engine uses to evaluate fetch().json() responses, so its strictness exactly matches what your runtime accepts. JSON.stringify with the third argument (the spacer) emits the canonical pretty-printed form. There's no third-party library, no WASM blob - just the standards-compliant parser already in your browser.
Validation runs live on every keystroke (with a 350 ms debounce on the auto-format pass). When parsing fails, the JSON.parse error message includes the position of the first bad character ("Unexpected token } in JSON at position 87"). The status strip surfaces that message verbatim, so you can jump to the offending byte and fix the dangling comma or unterminated string. When parsing succeeds, the stats panel walks the parsed tree and reports total keys, depth, array count, and null count - useful for spotting that a deeply nested config has 12 levels of nesting where you expected 3.
The Sort Keys option recursively alphabetizes every object's keys at every level of nesting (sortKeysDeep in the source above). This is the key step before diffing two JSON files, because JSON object keys are unordered by spec - two semantically-equal objects might serialize with different key orders depending on the producer. Sorting both sides first makes a textual diff actually meaningful. It's also the trick behind canonical JSON formats used for hashing and signing.
Indent sizes of 2, 4, or 8 spaces cover the three common conventions: 2 (Airbnb, StandardJS, most modern JavaScript codebases), 4 (Python-derived, older Java configs, legacy .NET appsettings.json), and 8 (rare but useful for very long single-line objects where 2-space indent makes structure hard to follow). Tabs aren't exposed because JSON.stringify accepts them but most consumer tools (jq, jsonlint) prefer spaces.
Minification produces JSON.stringify(parsed) with no spacer - the most compact valid representation. It strips all whitespace including newlines but cannot remove semantically-meaningful characters (the standard requires the commas, colons, brackets, and braces). For 100 MB+ payloads, the savings are around 20-30%; for small API responses, gzip compression on the wire is usually a bigger win. Use minify when you need to embed JSON in a URL, in a meta tag, or as a single-line value in a YAML file.
Two practical limits worth noting. First, JSON has no native support for cyclic references, infinity, NaN, undefined, BigInt, or Date objects - all of which JavaScript can express but JSON.stringify will silently strip or throw on. If your input came from JSON.stringify(myObj) where myObj had a Date, the date became a string. Second, the recursive parse / sort / stringify pipeline holds the full tree in memory; pasting a 200 MB JSON document will stall the tab. For files that big, use jq or pandas on the command line.

Common Use Cases

01

Inspecting API responses

Paste a minified JSON response from a fetch call or curl trace and see the structure pretty-printed for debugging.

02

Cleaning up package.json

Re-emit package.json with sorted keys before committing to make scripts and dependencies easier to scan in code review.

03

Pre-diff normalization

Sort keys on both old and new versions of a config file before running them through diff so unordered key changes don't generate noise.

04

Validating webhook payloads

Quickly check whether a payload that failed your parser is valid JSON or actually malformed at the byte level.

Frequently Asked Questions

Per RFC 8259: object keys must be double-quoted strings, no trailing commas after the last element, no comments, no single-quoted strings, no unquoted keys, and no special values like NaN or undefined. The parser here is the browser's built-in JSON.parse, so its strictness matches what fetch().json() accepts at runtime.
Yes. The Minify button calls JSON.stringify(parsed) with no spacer, producing the most compact valid output - all structural whitespace removed but nothing semantic. For network transport, gzip / brotli compression on top of formatted JSON usually beats minification alone.
All parsing, formatting, sort-keys traversal, and minification run as JavaScript in your tab. There's no upload, no analytics on the input, and no logging. The data is gone the moment you close the tab.
2, 4, or 8 spaces. Two is the modern JavaScript default; four matches Python and many older Java/.NET conventions; eight is rare but useful for very dense objects where small indents make structure hard to read. Tabs aren't exposed but JSON.stringify accepts them if you call it directly.
It walks the parsed tree and replaces every object with a new object whose keys are sorted alphabetically (using localeCompare). The transformation is recursive - keys at every level get sorted. This is the standard pre-step for textually diffing two JSON files, since JSON keys are unordered by spec.
When Auto is on, the formatter waits 350 ms after the last keystroke and then auto-runs Format on valid input. The debounce avoids re-formatting on every character; 350 ms is short enough to feel instant and long enough to skip mid-word redraws.
JSON.parse reports the byte offset of the first character it couldn't consume. Counting characters in your editor (most show row/column at the bottom) gets you to the bug fast. The most common causes: trailing comma after the last array/object element, missing comma between elements, or a string with an unescaped quote.
No - it uses standards-compliant JSON.parse, which rejects both. For tsconfig.json, .vscode/settings.json, and other JSONC files, strip comments first or use a tool like jsonc-parser. For JSON5 input, parse with the json5 npm package and re-stringify as standard JSON.
Parsing 1-10 MB of JSON is fast (sub-100ms on a modern laptop). Beyond ~50 MB the recursive walk used by sort-keys and the stats panel starts to feel sluggish, and Chromium tabs will throw out-of-memory errors above ~500 MB. For huge files use jq on the command line.
Yes - arrays are ordered by spec, so the formatter never reorders array elements. Sort Keys only affects the keys of objects. If your "array" is actually a misused object with numeric keys ("0", "1", "2"), Sort Keys will still alphabetize those keys, which can produce surprising results.

Step-by-step guide

How to format & validate JSON online

Walk through every step with screenshots, format-specific tips, and the platform-by-platform limits you need to know.

Advertisement