What is a JSON formatter?
API responses, config files and exports often come as a single unbroken line of JSON. It is valid, but you cannot read it, and a missing comma on line 400 of a minified file is almost impossible to spot. A JSON formatter turns that into an indented, colour-coded structure, and tells you when the text is not valid JSON at all.
This JSON formatter has four buttons: Format / Beautify, Minify, Validate Only and Clear. Pick an indent of 2 spaces, 4 spaces or Tab, and tick Sort keys A-Z if you want every object's keys alphabetised, which helps when you compare two files. The output panel colours strings, numbers, booleans, null and keys differently. After formatting, a green status line shows the line count and characters, and pills show formatted and minified size.
Validation relies on the browser's built-in JSON parser. Anything it rejects is shown with its message: single quotes, trailing commas, comments, unquoted keys. Browsers word these messages differently, and some include a position while others do not. The tool does not offer a tree view, repair broken JSON, or check data against a schema.
How to format and validate JSON
- Paste your JSON into the Input JSON box on the left.
- Choose an indent with 2 spaces, 4 spaces (the default) or Tab. Tick Sort keys A-Z if you want keys in alphabetical order.
- Click Format / Beautify. The coloured result appears on the right and a status line shows Valid JSON with line and character counts.
- Click Minify to get a single compact line, with a status showing how many characters it saved.
- Click Validate Only to check the JSON without producing output. If it fails, the message from the parser appears in a red box.
- Click Copy above the output to copy the last formatted or minified result, or Clear to reset everything.
What this JSON formatter does
Beautify with three indents
Format with 2 spaces, 4 spaces or a tab. Nesting is shown with the same indent at every level.
Syntax colouring
Keys, strings, numbers, booleans and null are shown in different colours on a dark panel, so a quoted number is easy to tell from a real one.
Sort keys A-Z
An option that alphabetises keys in every nested object. Arrays keep their order.
Minify
Strips all whitespace and reports the character count and percentage saved against the trimmed input.
Validate only
Parses the input and reports valid or invalid, without changing the output panel.
Size pills
After formatting, you get pills for lines, formatted size and minified size in characters.
Who uses it, and for what
- Front-end and back-end developers. Paste an API response and read the structure. Sort the keys before comparing two responses so differences stand out.
- QA and support teams. Check whether a payload in a bug report is valid JSON and, if not, where the parser gives up.
- WordPress and no-code builders. Tidy a JSON config for a plugin or block before editing. For rendered page code instead, the HTML formatter fits better.
- Data analysts. Inspect a JSON export, then move it elsewhere with JSON to HTML table or JSON to Markdown.
- Students. Learn the rules of JSON by breaking a sample on purpose and reading the error.
Tips, errors and limits
- All keys and strings need double quotes. Single quotes, unquoted keys, comments and trailing commas are all errors in JSON.
- Large integers lose precision. A number above 9007199254740991 is parsed as a floating-point value, so check IDs in the original data if they are very long.
- If an object has the same key twice, the later value wins and the earlier one disappears from the output.
- JavaScript puts keys that look like whole numbers, such as
"10"and"2", first in ascending order, even when you do not sort. Your formatted output can therefore differ from the input order. - Minify and Validate use the same parser as Beautify, so a document that fails to beautify will fail everywhere.
- To describe the shape of valid data, try JSON to JSON Schema.
Is it safe? Privacy and limits
Parsing, formatting and minifying all happen in your browser with built-in JavaScript. The text you paste is not sent to this site and is not saved. The tool cannot fix invalid JSON or check data against a schema, and error wording depends on your browser. Avoid pasting live API keys, tokens or personal records into any web page unless you trust the environment you are using.
JSON formatter FAQ
Paste the text into the input box, choose an indent and click Format / Beautify. If the JSON is valid, the right panel shows it indented and coloured, and a green line reports the line and character counts. If not, a red box shows the parser's message and nothing is output. You can then copy the result with the Copy button. The whole thing runs in your browser, so there is no upload and no account.
It runs the browser's JSON.parse and shows the message it throws. Chrome says something like Unexpected token and gives a position, while Firefox and Safari word it differently and may give a line and column. The tool does not add its own line highlighting, so for a long file use the position number to find the spot. Typical culprits are a trailing comma, a single quote or a missing closing bracket.
Format parses your JSON and prints it with indentation and colours. Minify prints it with no whitespace at all, which is the smallest valid form. Validate Only just reports whether the text parses, and leaves the output panel untouched. All three use the same parser, so valid input is valid for all of them. Minify and Format may change the layout of numbers or key order slightly, but not the data.
It sorts the keys of every object, at every depth, in alphabetical order before printing. Arrays are not reordered, because order matters there. It is useful when you want to compare two JSON files with a diff tool, since the same data then looks the same. Sorting is applied only when you click Format or Minify, and the original in the input box does not change. Keep a copy of the original input, and test again after any change.
No. It tells you the document is invalid but does not repair it. You have to fix the problem yourself: remove a trailing comma, change single quotes to double quotes, add missing quotes around a key, delete comments, and replace undefined with null. After each change, click Validate Only until it passes. If your data is JavaScript, not JSON, convert it to strict JSON first. Keep a copy of the original input, and test again after any change.
The values stay the same, with three small exceptions caused by how JavaScript reads JSON. Numbers with more than about 15 significant digits lose precision, duplicate keys collapse into one, and keys that look like integers are moved to the front in ascending order. Whitespace and the visual layout change on purpose. Do not rely on the formatted copy for exact big-number IDs; keep the original. Keep a copy of the original input, and test again after any change.
No. The page uses JavaScript in your browser to parse and print the text, and this tool sends nothing to a server. Nothing is stored either, so closing the tab clears it. Even so, treat tokens, passwords and personal data with care: anyone with access to your screen or browser extensions can see what you paste. Remove secrets from samples before sharing them. Keep a copy of the original input, and test again after any change.
This tool only formats, validates and minifies JSON. To convert it, use a dedicated tool: JSON to XML for XML, JSON to HTML table for a web table, or JSON to Markdown for documentation. Each of them reads JSON the same way, so valid JSON from this page will work there. A quick validation first saves you from confusing conversion errors. Keep a copy of the original input, and test again after any change.