JSON Formatter & Validator
Format, validate, and beautify JSON online. Errors come with the exact line, a pointer, and a plain-English fix, and long IDs stay exact instead of being silently rounded. Minify it, browse it as a tree, or sort the keys — free, and your JSON never leaves your browser.
Formatted JSON will appear here… JSON escape & unescape
Turn text into a JSON string — quotes become \" and line breaks \n — or turn an escaped string back into plain text. Handy for putting text into code or reading escaped values from logs.
Readable JSON — or the exact reason it isn’t
Exact error line and fix • Beautify, minify & tree view • Sort keys • Escape strings • Long numbers kept exact • Nothing leaves your browser
Format, validate, and explore JSON in one place
APIs, log files, and build tools hand out JSON minified — one endless line with no spaces. Paste it above and it’s instantly indented, color-coded, and checked. The Formatted view uses 2 spaces, 4 spaces, or tabs; Minified packs it back into the smallest valid form; and the Tree view lets you fold big documents open one branch at a time, with a count of keys and items on every node. Copy the result or download it as a .json file.
Validation happens in the same step. When the JSON is broken, you don’t just get “Unexpected token”: you get the line and column, the offending line with a pointer under the exact character, and a short explanation of what to change — the same answer in Chrome, Firefox, and Safari.
Common JSON errors (and how to fix them)
JSON is stricter than the JavaScript it came from. These are the mistakes the validator sees most:
| Invalid | Why it fails | Valid |
|---|---|---|
| {"a": 1,} | Trailing comma after the last item — JavaScript tolerates it, JSON doesn’t. | {"a": 1} |
| {'a': 1} | Single quotes — JSON only accepts double quotes. | {"a": 1} |
| {a: 1} | Unquoted key — every key must be a string in double quotes. | {"a": 1} |
| {"a": 1 // note} | A comment — JSON has no comment syntax at all. | {"a": 1} |
| {"a": undefined} | undefined, NaN, and Infinity don’t exist in JSON. | {"a": null} |
| {"a": True} | Python’s True, False, and None instead of true, false, and null. | {"a": true} |
| {“a”: 1} | Curly “smart” quotes pasted from Word, Google Docs, or Slack. | {"a": 1} |
| {"dir": "C:\Users"} | A lone backslash — \U isn’t a valid escape sequence. | {"dir": "C:\\Users"} |
One error usually isn’t a typo at all: “Unexpected token <”. It means the text starts
with < — the server sent an HTML page (a 404, a 500, or a login screen) where your code
expected a JSON response. Paste the response here and the validator says so outright. The fix is on the
request side: the URL, the authentication, or the status code.
Smart quotes: the JSON error you can’t see
Word, Google Docs, Pages, Outlook, Slack, and macOS itself replace straight quotes with curly
“smart” quotes as you type. In a paragraph that’s typography; in JSON it’s a syntax error —
and a sneaky one, because “name” and "name" look nearly identical on screen. If JSON
has passed through a document, an email, or a chat message, the validator tells you when a curly quote is
the culprit and points at the first one. The fix is to swap them for straight quotes, or to share JSON as a
file or a code block next time.
Sneakier still are invisible characters. A non-breaking space added by Teams, Outlook, or a web page looks exactly like a regular space, yet JSON doesn’t allow it outside strings — and the browser only reports an “unexpected character”. The validator names it (U+00A0), shows it as · in the excerpt, and swaps every one of them for a regular space in a single click, leaving text inside quotes untouched.
Long numbers stay exactly as written
Every number in JavaScript is a 64-bit float, which can hold whole numbers exactly only up to
9,007,199,254,740,991 (2⁵³ − 1). Real-world IDs regularly go past that — 64-bit database
keys, X (Twitter) post IDs, Discord snowflakes. A typical browser-based formatter parses the JSON with
JSON.parse, so 1826574838290192385 silently comes back as
1826574838290192400, and you end up debugging an ID that doesn’t exist.
HandyTray validates with the browser’s own parser but reads the values with a lossless one, so long
integers and high-precision decimals appear exactly as they were written — formatted, minified, sorted, or
in the tree. Key order survives too, even numeric keys like "2026" and "2025",
which JavaScript would otherwise move to the front and sort. The sample JSON above contains a long ID; when
you paste such numbers, you’ll also get a heads-up,
because your own code will round them the moment it calls JSON.parse. It’s also why APIs
such as X’s and Discord’s send their IDs as strings.
Your JSON stays in your browser
JSON you’re debugging is rarely harmless: API responses carry access tokens, customer emails, and internal IDs. That matters more than it sounds — in November 2025, security researchers reported that more than 80,000 JSON snippets people had saved on popular online formatters were reachable by others, passwords, cloud keys, and private keys included.
This formatter has no save or share feature, no account, and no server that ever sees your data: formatting and validation run entirely in your browser. Load the page, switch off Wi-Fi, and it keeps working.
Comparing two versions of the same file? JSON Compare lists every difference with its path. Holding a JWT? Its payload is Base64-encoded JSON — our Base64 decoder unpacks it in one step.
JSON formatter FAQ
Validation errors, long numbers, minifying, and keeping your data private.
What does a JSON formatter do?
It takes JSON — usually squeezed into one long line by an API or a build tool — and lays it out with indentation and line breaks so a human can read it. This one validates while it formats: if the JSON is broken, you get the exact line and column of the problem and a plain-English explanation instead of formatted output.
How do I validate JSON?
Paste it into the box above or open a .json file. Validation runs as you type: a green bar means the JSON is valid; a red one names the line and column of the first error, points at it, and tells you what to change — a trailing comma, a missing quote, a curly quote from Word, and so on.
Why does my JSON fail validation?
The usual suspects are a comma after the last item, single quotes, keys without quotes, comments, and values like undefined or NaN that only exist in JavaScript. Text pasted from Word, Google Docs, or Slack often carries curly quotes that look almost identical to straight ones. Python dictionaries printed with print() fail too — they use single quotes and True, False, and None.
Why do I get “Unexpected token < in JSON at position 0”?
Because the text starts with < — your code asked for JSON and received an HTML page instead: a 404, a 500 error page, or a login screen. The JSON isn’t broken; the request is. Paste the response here and the validator says so outright. Then check the URL, the authentication, and the response status code.
What is the difference between JSON and a JavaScript object?
JSON is a stricter, text-only subset: keys and strings must use double quotes, and there are no comments, trailing commas, functions, or undefined values. Every JSON document is valid JavaScript, but not the other way around — which is why an object copied from source code usually fails validation until you run it through JSON.stringify().
Why do long numbers change in other JSON tools?
JavaScript stores every number as a 64-bit float, which holds whole numbers exactly only up to 9,007,199,254,740,991 (2⁵³ − 1). Longer IDs get rounded, so 1826574838290192385 quietly becomes 1826574838290192400 in most browser-based formatters. HandyTray reads numbers losslessly and prints them exactly as they were written — and warns you, because JSON.parse in your own code would round them too.
What is minified JSON for?
Minified JSON drops every space and line break, so it is as small as possible — the right form for API responses, config you ship to production, or data you embed in a page. Formatted JSON is for reading and debugging. Switch between the two with one click, and copy or download either version.
Can I sort JSON keys alphabetically?
Yes — tick Sort keys and every object in the document is ordered A–Z, at every level of nesting. It makes two versions of a file much easier to compare by eye. To compare them properly, use JSON Compare, which ignores key order entirely and lists every added, removed, and changed value.
Is it safe to paste API responses or tokens here?
Yes. Formatting and validation run entirely in your browser — the JSON is never uploaded, stored, or logged, and the page keeps working with the internet switched off. There is no save or share feature either, so nothing you paste can end up on a public link.
Need random IDs for test data? The UUID generator makes version 4 UUIDs in bulk.