JSON Formatter & Validator
Format, validate and minify JSON with exact error locations and a collapsible tree view.
- Free
- No sign-up
- Runs in your browser
What is a JSON formatter and validator?
A JSON formatter takes compact or messy JSON and rewrites it with consistent indentation so you can actually read it. A validator checks that the text is legal JSON and, when it is not, tells you where it breaks. This tool does both in one place: paste JSON or load a file, then format it with 2 spaces, 4 spaces or tabs, minify it back to a single line, or validate it.
When validation fails, you get the exact line and column of the first error plus a plain-English hint about the likely cause. The most common culprits are a trailing comma after the last item, single quotes instead of double quotes, an unquoted object key, and comments, none of which the JSON standard allows even though JavaScript does.
Valid JSON can also be explored in a collapsible tree view. Each object and array shows how many children it holds, so you can fold away a 400-item array and focus on the one nested field you care about. A sort keys option orders object keys alphabetically, and you can copy the result or download it as a file. Everything runs in your browser, and files of 10 MB and larger are handled without freezing the page.
How to format and validate JSON online
- 1
Paste JSON or load a file
Paste text into the input box, or load a .json file from your computer. Large API exports and log dumps work fine because nothing is sent to a server.
- 2
Choose an indentation style
Pick 2 spaces, 4 spaces or tab. Two spaces is common in JavaScript projects and package.json files; four spaces matches many Python and Java codebases.
- 3
Format, minify or validate
Format pretty-prints the data, minify strips all optional whitespace, and validate confirms the syntax. If there is an error, jump to the reported line and column and read the hint.
- 4
Explore the tree view
Switch to the tree to collapse and expand objects and arrays. Node counts show the size of each branch at a glance. Turn on sort keys if you want a stable, alphabetical order.
- 5
Copy or download the result
Copy the output to your clipboard or download it as a file, ready to commit, paste into a request body or attach to a ticket.
When developers and SEOs use a JSON formatter
Debugging API responses
A minified response from a REST endpoint or webhook is one unreadable line. Formatting it reveals the structure, and the tree view makes it easy to confirm whether a field is missing, null or nested one level deeper than expected.
Checking JSON-LD structured data
Schema markup is JSON, and a single trailing comma makes Google ignore the whole block. Paste the contents of your JSON-LD script here first to catch syntax errors before you test rich result eligibility.
Fixing broken config files
Files like package.json, tsconfig.json, composer.json and VS Code settings fail with vague parser errors. The line, column and hint point straight at the stray comma or comment.
Comparing data cleanly
Sorting keys and using the same indentation for two payloads makes them line up, so a diff shows real changes instead of reordered fields.
Shrinking payloads
Minify JSON before embedding it in an HTML attribute, an environment variable or a test fixture where whitespace only adds bytes.
Common JSON errors and how to fix them
Trailing commas are the number one cause of invalid JSON. A comma after the last element of an array or the last property of an object is fine in modern JavaScript but illegal in JSON. Delete it and the error disappears.
Single quotes are not allowed for strings or keys. JSON requires double quotes everywhere, so a value written as 'active' must become a double-quoted string. This often happens when someone copies a JavaScript object literal or Python dictionary and treats it as JSON.
Unquoted keys are another JavaScript habit. In JSON, every key must be a double-quoted string, including simple ones like id or name. Comments, whether line comments starting with two slashes or block comments, are also invalid. Some tools accept a JSON-with-comments dialect for config files, but standard parsers, including the ones behind most APIs, reject them.
Other errors worth knowing: values such as undefined, NaN and Infinity are not valid JSON; numbers cannot have leading zeros; and control characters inside strings, like a raw tab or newline, must be escaped. The validator reports only the first error, so fix it, validate again and repeat until the input passes.
Frequently asked questions
Is the JSON formatter free?
Yes, the JSON formatter and validator is completely free, with no sign-up and no usage limits. You can format, minify, validate, sort keys and explore the tree view as often as you like. It is designed for developers, SEOs working with structured data and anyone who needs to read or fix JSON quickly without installing an editor extension.
Is my JSON uploaded to your server?
No, your JSON never leaves your browser. Parsing, formatting, validation and the tree view all run locally in JavaScript on your device, and files you load are read directly by the browser. That makes the tool safe for API responses containing tokens, customer records or internal configuration that you should not paste into a third-party service.
Can it handle large JSON files?
Yes, the tool handles large files, including JSON of 10 MB and more. Because processing happens on your own machine, speed depends on your device rather than an upload limit. For very large documents, the collapsible tree view is the practical way to navigate, since you can keep big arrays folded and open only the branches you need.
Why does my JSON fail validation when it works in JavaScript?
JavaScript object literals allow things that JSON forbids. Trailing commas, single-quoted strings, unquoted keys, comments and values like undefined all work in a script but break a JSON parser. The validator flags the first such problem with its line, column and a hint, so you can convert the object into strict JSON one fix at a time.
What is the difference between formatting and minifying?
Formatting adds line breaks and indentation for readability, while minifying removes every optional space and newline to make the data as small as possible. Both produce identical data when parsed. Use formatted JSON for reading, reviewing and committing to version control, and minified JSON when size matters, such as in network payloads or inline scripts.
Does sorting keys change my data?
No, sorting keys changes only the order in which object properties appear, not their values. JSON objects are unordered by definition, so any compliant parser treats the sorted and unsorted versions as the same data. Array order is never changed, because in arrays position is meaningful. Sorted output is especially useful when comparing two payloads.
Related tools
More Developer tools →Base64 Encoder & Decoder
Encode or decode Base64 text and files — UTF-8 safe, URL-safe variant and data URIs.
Developer · In-browser
URL Encoder & Decoder
Percent-encode or decode URLs and inspect every part — host, path and query parameters.
Developer · In-browser
Redirect Generator
Turn old → new URL lists into redirect rules for Apache, Nginx, Cloudflare, Vercel and more.
Developer · In-browser
QR Code Generator
Free QR codes for links, Wi-Fi, vCards, email and WhatsApp — with your logo, colours and SVG/PNG export.
Developer · In-browser