JSON formatter, validator and minifier
Beautify, minify and validate JSON with the exact line and column of any error, sort keys, escape strings and generate TypeScript interfaces.
- Runs in your browser
- Files are never uploaded
- Free, no account
176 characters · 176 B
- Nodes
- 12
- Depth
- 3
- Keys
- 9
- Objects
- 2
- Arrays
- 1
- Strings
- 4
- Numbers
- 3
- Size
- 176 B
Tip: press Tab to move between the panes.
How to format JSON
- Paste your JSON into the input pane, or use Load file to open a
.jsonfile from disk. - Choose Beautify and pick 2 spaces, 4 spaces or a tab. The output pane updates as you type.
- If the document is invalid, the error panel names the line, column and character offset of the first problem and prints the offending line with a caret under it.
- Switch to Minify to strip every optional byte, or TypeScript to generate interfaces from the shape of the data.
- Copy the result, download it, or open the same document in the tree viewer for large payloads.
Reading the error message
JSON is a deliberately small grammar, so almost every parse failure comes from one of a handful of causes. The validator reports the raw engine message plus a plain-English hint when it can recognise the pattern.
| What you wrote | Why it fails | Fix |
|---|---|---|
{"a": 1,} | Trailing comma before } | Delete the comma |
{'a': 1} | Single quotes are not JSON strings | Use double quotes |
{a: 1} | Unquoted key | Quote every key |
{"a": 01} | Leading zeros are not valid numbers | Write 1 |
{"a": NaN} | NaN and Infinity are not JSON values | Use null or a string |
// comment | JSON has no comments | Strip them, or use JSON5 in your own tooling |
Smart quotes “a” | Pasted from a word processor | Retype with straight quotes |
Beautify or minify — which do you want?
Whitespace has no meaning in JSON, so both forms parse to exactly the same value. Beautified JSON is for humans: code review, debugging an API response, checking a config file into version control where a line-based diff needs to be readable. Minified JSON is for machines: it removes every space and newline, typically cutting 15–30% off a formatted document before compression even starts.
One caveat worth knowing: minifying does not change the number of bytes your users download by nearly as much as you would expect, because gzip and brotli already compress repeated indentation extremely well. Minify for storage limits and payload caps, not as a performance optimisation on a compressed transport.
Sorting keys for comparison
Object member order carries no meaning in JSON, but a text diff does not know that — two API responses with identical content can produce a wall of false changes purely because the server serialised the keys in a different order. Turn on Sort keys A→Z on both documents before diffing and the noise disappears. Array order is meaningful and is never touched.
Generating TypeScript interfaces
The TypeScript mode walks the parsed value and emits one exported interface per distinct nested object,
named after the key that contains it. For arrays it merges the shapes of every element: a field present
in all elements is required, a field present in only some is marked optional with ?, and a
field with more than one type becomes a union. Empty arrays produce unknown[], because a
sample of zero tells you nothing about the element type.
Treat the output as a first draft. Generated types describe the sample you pasted, not the contract the API promises — a field that happens to be non-null in your sample may be nullable in production. Check the generated interfaces against the API documentation before committing them.
Escaping and unescaping
Escape turns the whole input into a single JSON string literal, quotes and all — useful
when you need to embed a JSON document inside another JSON document, a common requirement for webhook
payloads and log fields. Unescape reverses it, turning "{\"a\":1}" back
into a document you can format.
Privacy
Everything on this page runs as JavaScript inside your browser tab. There is no upload step, no background request and no logging, which is why it is safe to paste API responses containing customer records, internal identifiers or bearer tokens. Load the page once and it keeps working with the network disconnected.
Questions
Why does my JSON fail to parse when it looks fine?
The usual causes are a trailing comma before a closing brace or bracket, single quotes instead of double quotes, unquoted keys, or a stray comment. The error panel gives the line, column and character offset of the first problem so you can jump straight to it.
Is my JSON uploaded anywhere?
No. Parsing, formatting and validation all run in JavaScript inside this tab. Nothing is transmitted, which is why the tool is safe for API responses containing customer data or access tokens.
How large a document can it handle?
Documents in the tens of megabytes work on a normal laptop; the practical ceiling is your browser tab memory. Very large files are faster to minify than to beautify because beautifying produces more characters than it consumes.
What does the TypeScript interface generator produce?
It walks the parsed value and emits named interfaces for every nested object, merging the shapes of array elements and marking a field optional when it is absent from some elements. Mixed types become unions.
Does sorting keys change the meaning of my JSON?
No. Object member order is not significant in JSON, so sorting is safe for comparison and diffing. Array order is meaningful and is never changed.