JSON Formatter & Validator
Paste JSON, get it beautified, minified or validated with the exact line and column of the problem. Everything runs in your browser.
Large input — processing runs when you stop typing (300 ms) or press Run now.
📊 Stats
📤 Output
📄 JSON → CSV
Works when the top level is an array of flat objects.
🧰 String escape / unescape
How to use the JSON formatter
- Paste or type your JSON into the input box, or press Load sample to see the tool working.
- Pick what you want: Beautify to indent it, Minify to strip whitespace, or Validate only to check it without producing output.
- Choose the indent width (2 spaces, 4 spaces or a tab) and, if you want a stable ordering, turn on Sort keys.
- The result appears 300 ms after you stop typing. Use Copy or Download .json to take it away.
- If the JSON is broken, read the red banner: it names the problem and points at the exact line and column with a caret.
How validation and error location work
The tool hands your text to the browser’s built-in JSON.parse, which is the same parser your application will use. That gives you an authoritative yes or no rather than a second opinion from a hand-written parser.
The catch is that error messages are not standardised. The same broken document produces three different sentences depending on the engine:
| Engine | Message shape |
|---|---|
| V8 (older Chrome, Node) | Unexpected token } in JSON at position 12 |
| V8 (current) | Expected ',' or '}' after property value in JSON at position 19 (line 3 column 7) |
| SpiderMonkey (Firefox) | JSON.parse: unexpected character at line 3 column 7 of the JSON data |
| JavaScriptCore (Safari) | JSON Parse error: Expected '}' — no position at all |
So the tool reads whichever of those it is given: a line/column pair if present, otherwise a character offset that it converts to a line and column by counting newlines. When the engine offers neither — Safari’s case — a small built-in JSON scanner walks the text and reports the offset of the first character that cannot legally appear there. The result is that you always get a caret under the offending character, on every browser.
A few examples of what that catches:
{"a" 1}— a missing colon after a property name, reported at column 6.[1,2,]— a trailing comma, reported at the closing bracket.{"a":"oops}— an unterminated string, reported at the end of input.[01]— a number with a leading zero, which JSON forbids even though JavaScript once allowed it.
Worked examples
Minifying a config payload. The built-in sample object is 142 bytes minified and 199 bytes pretty-printed with two spaces. Beautifying costs about 40% more bytes; on a response served with gzip or Brotli the difference mostly disappears, because repeated indentation compresses extremely well. Minify for the wire, beautify for the eye.
Sorting keys for a clean diff. Two services emit the same settings object with keys in different orders. Pretty-printing both with Sort keys on turns a 40-line diff into a two-line one, because the only remaining differences are the values that actually changed.
JSON to CSV. Given [{"id":1,"name":"Ada"},{"id":2,"name":"Alan"}], the tool writes the header id,name and two data rows. If the second object had an extra email key, the column would be appended at the end and the first row would simply have an empty cell. Values containing a comma, a quote or a newline are wrapped in double quotes with internal quotes doubled, following RFC 4180.
Reading the stats
- Input size / output size are UTF-8 byte counts, not character counts, so a document full of emoji or Korean text reports the size your server will actually send.
- Keys counts every object key in the document, including nested ones — a quick sanity check that a payload contains what you expect.
- Max depth is the nesting level: a scalar is 0,
[1]is 1, and{"a":{"b":1}}is 2. Deeply nested payloads are worth watching because many parsers and schema validators have depth limits. - Values counts every node in the tree, which is a rough proxy for how expensive the document is to parse.
Common mistakes to avoid
- Trailing commas.
{"a":1,}is valid in modern JavaScript source, in JSON5 and in most config formats, but not in JSON. Remove the last comma. - Single quotes. JSON strings must use double quotes.
{'a':1}fails immediately. - Unquoted keys.
{a:1}is a JavaScript object literal, not JSON. NaN,Infinityandundefined. None of these exist in JSON. Serialisers usually turn them intonull; if you see them in a file, something wrote raw JavaScript instead of JSON.- Comments. JSON has none.
//and/* */will both fail. If you need comments in a config file, use JSONC, YAML or TOML, or park the text in a dummy key like"_comment". - A byte-order mark. A UTF-8 BOM at the start of a file makes
JSON.parsefail on the very first character. Strip it before parsing. - Escaping twice.
"{\"a\":1}"is a string that contains JSON, not JSON. Use the unescape panel on this page to unwrap it first.
Glossary
- Beautify / pretty-print – re-emit the same data with newlines and indentation.
- Minify – re-emit the same data with all optional whitespace removed.
- Escape – convert a raw string into a JSON string literal, so quotes, backslashes and newlines survive transport.
- Depth – how many levels of objects and arrays are nested inside each other.
Privacy
Nothing you paste is sent to a server. The tool parses, formats and converts entirely in your browser tab using the JavaScript engine already running there; no request carries your data, nothing is logged, and closing the tab discards everything. That makes it safe for API responses, tokens and other payloads you would not want to paste into a hosted service.
Frequently asked questions
Why does my JSON fail to parse when it looks fine?
The three usual culprits are a trailing comma before a closing bracket, single quotes instead of double quotes, and unquoted property names. All three are valid JavaScript object literals but invalid JSON, so an editor that highlights JS happily will still produce a file that JSON.parse rejects.
Does this tool upload my JSON anywhere?
No. Parsing, formatting and CSV export all run in JavaScript on your device. There is no upload request, no logging and no storage of your input on a server.
What is the difference between beautify and minify?
Beautifying adds newlines and indentation so a human can read the structure. Minifying strips every byte of optional whitespace so the payload is as small as possible. Both produce exactly the same data, so a service reading the JSON cannot tell them apart.
Is sorting keys safe?
Yes for data, because JSON objects are unordered by specification and every parser gives you the same values either way. It is not safe for anything that hashes or signs the raw text, such as a webhook signature or a lockfile checksum, because the bytes change.
How large a file can I paste?
A few megabytes is comfortable on a modern laptop. The work is synchronous, so a very large document may freeze the tab for a moment while it parses; the tool waits until you stop typing before it starts.
Can I convert JSON to CSV here?
Yes, when the top level is an array of objects. Columns are the union of every key in first-seen order, missing values become empty cells, and nested objects or arrays are written back as JSON text inside the cell.
Related tools
- Base64 Encoder & DecoderConvert text, files and data URIs to and from Base64 with correct UTF-8 handling, a URL-safe option and MIME line wrapping. Nothing is uploaded.
- Unix Timestamp ConverterA live epoch clock, instant timestamp-to-date conversion in UTC and your local time, a date-to-timestamp direction, and a batch mode for whole log columns.
- Cron Expression GeneratorWrite a cron expression in Unix, Spring or Quartz form, read what it actually means in English, and see the next ten fire times in UTC and your local time.
- Password GeneratorBuild a random password or a memorable passphrase with real cryptographic randomness. Entropy, strength and crack time are shown for the exact options you picked — and nothing ever leaves your browser.
- UUID GeneratorCreate random or time-ordered identifiers in bulk, format them for JSON, CSV or a SQL insert, and paste any existing id to find out which version it is and when it was made.
- Hash GeneratorCompute SHA and CRC32 digests of text or files entirely in your browser, switch between hex and Base64, sign messages with HMAC, and check two hashes against each other.
Last reviewed: