JSON Formatter & Validator
Paste JSON to pretty-print, minify or validate it. Errors show the line and column.
Enter valid JSON to see it as a tree.
$Runs entirely in your browser. Nothing you enter is sent or stored.
How to use
- Paste or type JSON into the box.
- Choose an indent size.
- Click Format to beautify or Minify to compress.
- Copy or download the result.
API responses, log lines and config files often arrive as one long line of JSON that is hard to read. This JSON formatter pretty-prints it with 2 spaces, 4 spaces or tabs, or does the opposite and minifies it into a single line with all extra whitespace removed. The result replaces the input, ready to copy or download as formatted.json.
Parsing uses the browser's built-in JSON.parse, which follows the strict JSON standard (RFC 8259 / ECMA-404). That makes it a quick JSON validator too: if parsing fails you get the browser's error message, and when that message contains a character position it is converted to a line and column so you can go straight to the problem. Typical causes are trailing commas, single quotes, unquoted keys and comments.
Because the text is parsed into JavaScript values and written back out, a few details can change. Integers larger than 2^53 lose precision, if a key appears twice only the last value is kept, keys that look like non-negative integers move to the front of their object, and 1.0 is written as 1. Comments and JSON5 syntax are not accepted. Everything happens in your browser; the JSON you paste is never uploaded or stored.
Use cases & tips
Finding one value in a large response
After formatting a long API response, the tree view is faster than scrolling. Collapse everything, open only the branch you need, or type part of a key or value in the search box and the matches are highlighted with their parents expanded. Clicking a node shows its path, such as $.data[0].email, which you can copy into code. For many values at once, the JSONPath box takes queries like $.store.book[*].author and lists every author in the result.
Fixing JSON that almost works
Hand-written or copied data is often nearly valid. The Repair button removes comments, turns single quotes into double quotes, quotes bare keys, drops trailing commas and changes True, False and None to true, false and null. So {'name': 'uhub', enabled: True,} becomes {"name": "uhub", "enabled": true}. The result is only applied if it now parses. Values such as NaN, Infinity and undefined become null, which changes the data, so read the result before using it.
JSON stored inside a string
Logs and database columns often hold JSON as an escaped string, full of \" sequences, for example "{\"id\":1,\"ok\":true}". Paste it and press Unescape to get the plain text back, then Format it. Escape does the opposite: it turns your JSON into a string literal you can paste into source code or into another JSON value without breaking the quotes. If the input is not a valid escaped string, you get a message instead of a changed text.
Sorting keys for comparison
Two objects with the same content but a different key order look different in a diff tool. Turn on Sort keys and every object, at every depth, is arranged alphabetically, so the real differences stand out. Arrays keep their order, because the order of items in an array usually carries meaning. Uppercase letters sort before lowercase ones, and the sorted text replaces the input, so copy the original first if you need it. Use Open file for larger files instead of pasting.
Frequently asked questions
Is my JSON uploaded anywhere?
No. Formatting happens in your browser with JavaScript. Nothing is sent to a server.
Why does it say my JSON is invalid?
Common causes are trailing commas, single quotes, or unquoted keys. The message shows the line and column of the first error.
How large a file can I format?
Several megabytes work fine on most devices because nothing is uploaded.