How to use JSON Formatter & Validator
What it does & when you need it
You've pulled a JSON response from an API, a log line, or a config file, and it's a single unreadable line — or it won't parse and you can't see why. This tool pretty-prints JSON so you can actually read it, validates it against the JSON grammar, and when parsing fails it tells you the line and column where it broke. Everything runs in your browser using the same JSON engine your code uses, so a payload full of access tokens or customer data never leaves your machine.
How to use
- Paste your JSON into the input.json buffer, or press Sample to load an
example. You can also Upload a
.jsonfile. - The output updates as you type. Choose an Indent (2 spaces, 4 spaces, or a tab), toggle Sort keys for a canonical ordering, or hit Minify to collapse everything to one line.
- The input status bar shows
valid JSON ✓or the exact error position. Press Format (orCtrl/Cmd+Enter) to re-run, and Copy to grab the result.
Things worth knowing
JSON is stricter than JavaScript. The format is defined by ECMA-404 and RFC 8259, and it does not allow the things editors let you get away with: no trailing commas, no comments, no single-quoted strings, and every object key must be a double-quoted string. If validation fails, one of those is almost always the reason.
Formatting never changes the data. Whitespace between tokens is insignificant, so minifying and pretty-printing produce byte-for-byte different text but the exact same parsed value. Minify for the wire, indent for humans. The one transformation that can change meaning is sort keys — it reorders object members (arrays are left alone), which is what you want before diffing two payloads but not if some downstream consumer wrongly depends on key order.
Numbers and duplicate keys have sharp edges. JSON numbers are IEEE-754 doubles, so an integer beyond 2^53 (a Twitter/X snowflake ID, say) loses precision the moment it's parsed — keep those as strings. And if an object contains the same key twice, the parser keeps the last one; this tool will show you the collapsed result, which is a quick way to catch a generator emitting duplicate keys.
Errors point at a location when the engine provides one. Modern JavaScript engines report a character position for most syntax errors, which the tool converts to a line and column. Some short-input errors omit the position; in that case you still get a plain-English message.
Once your JSON is clean, you might want to decode a JWT whose payload is JSON, or convert a Base64 string that contains an encoded JSON body.