JSON Formatter & Validator
Paste JSON to pretty-print or minify it, find the exact line and column of any error, sort keys and explore it as a collapsible tree.
Runs entirely in your browser. Nothing you add is sent to us.
Create a free account to use the JSON Formatter & Validator
Free forever for this tool. Takes a few seconds — then you come straight back here.
- All 150 free tools, one login
- Free website audit with fixes
- Search Console dashboard
- Free keyword rank tracker
Already have an account? Sign in
A JSON formatter turns a dense block of JSON into neatly indented, readable text, and a validator tells you whether it is actually valid. Our free tool does both as you type. Paste an API response, a config file or a JSON-LD snippet to pretty-print it with two spaces, four spaces or tabs, or minify it to a single line. If something is wrong, you get the exact line and column, a plain-English explanation and a highlighted extract showing where the problem is. You can also sort keys alphabetically, explore the data as a collapsible tree, and copy or download the result. Everything runs in your browser, so the data never leaves your device.
How to use the JSON formatter
- 1 Paste or open your JSONPaste JSON into the box, open a .json file from your computer, or load the sample to see how it works. It is checked automatically a moment after you stop typing.
- 2 Fix any errorsIf the JSON is invalid, the result panel shows the line and column, explains what is wrong and highlights the spot. Use Show in editor to jump straight to it.
- 3 Choose format or minifyFormat adds line breaks and indentation for reading. Minify removes all unnecessary whitespace for the smallest possible size.
- 4 Set indentation and sortingPick two spaces, four spaces or tabs, and tick Sort keys A–Z if you want object keys in alphabetical order, which makes two files easier to compare.
- 5 Copy, download or exploreCopy the result, download it as a .json file, or switch to the tree view to expand and collapse nested objects and arrays.
What JSON is and why formatting matters
JSON, short for JavaScript Object Notation, is the most common format for sending structured data between systems. APIs return it, web apps store settings in it, analytics exports use it, and search engines read structured data written as JSON-LD. It is built from just a few pieces: objects in curly brackets holding key and value pairs, arrays in square brackets holding lists, and simple values such as strings, numbers, true, false and null.
Machines do not care about layout, so JSON is often sent as one long line with no spaces at all. That is efficient, but almost impossible for a person to read. Formatting puts each key on its own line and indents nested objects, so you can see the structure at a glance, spot a missing field or compare two responses. Minifying does the opposite, stripping whitespace to make a file as small as possible before you send or store it. The data itself is identical either way.
How the validator finds the exact error
Browsers include a built-in JSON parser, but its error messages vary from one browser to another and some do not give a position at all. To give you a reliable answer, this tool runs its own strict check whenever the built-in parser rejects your text. It walks through the JSON character by character, and the moment it finds something that breaks the rules it records the position and turns it into a line and column number.
The message explains what was expected, not just what was found. Instead of an unexpected token, you might see that a comma is missing between two properties, that a string was never closed, or that a property name needs double quotes. The highlighted extract shows the surrounding lines with a marker under the problem character, and very long minified lines are trimmed around the error so you are not scrolling sideways through thousands of characters.
Even when JSON is valid, the tool warns you about two quieter problems. Duplicate keys in the same object are allowed by the parser, but only the last value survives, which can hide a bug. Very large integers, such as long database IDs, lose precision in JavaScript, so the tool flags them and suggests storing them as strings.
The most common JSON errors
Most invalid JSON comes from a short list of habits carried over from JavaScript, Python or hand editing. JSON looks like JavaScript but follows stricter rules, so code that runs happily in a browser console can still be rejected by an API.
- Trailing commas: a comma after the last item in an object or array, such as {"a": 1,}, is not allowed in JSON even though JavaScript accepts it.
- Single quotes: every string and every property name must use straight double quotes. Curly quotes pasted from a word processor also cause errors.
- Unquoted keys: {name: "Ana"} is valid JavaScript but not valid JSON. It must be {"name": "Ana"}.
- Comments: JSON has no comment syntax, so // and /* */ notes must be removed before the file is parsed.
- Missing commas or brackets: usually caused by copying part of a larger file or editing by hand. The error position points to where the parser realised something was missing, which may be just after the real mistake.
- Python-style values: True, False and None must be written as true, false and null. NaN, Infinity and undefined have no JSON equivalent at all.
Indentation, minifying and sorting keys
Two-space indentation is the most common choice for JSON in web projects and keeps deeply nested data from drifting too far to the right. Four spaces is popular in some style guides and can be easier to scan. Tabs let each person set their own width in their editor. None of these changes the meaning of the data, so use whatever your project or team already uses.
Minified JSON is best for anything a machine reads: API requests, values stored in a database, data embedded in a page, or files bundled into an app. Removing whitespace typically reduces size noticeably for heavily indented files, and the tool shows the size before and after so you can see the difference for your own data.
Sorting keys puts every object's properties in alphabetical order, all the way down. This is useful when you want to compare two versions of a response or configuration file, because the same data always produces the same order, so a diff tool shows only real changes. Arrays are never reordered, because the order of items in a list usually matters. One quirk to know: JavaScript always lists keys that look like whole numbers first, in numeric order, before other keys.
Using the tree view
For large or deeply nested JSON, the tree view is often quicker than scrolling. Each object and array becomes a collapsible branch that shows how many items it holds, so you can open only the parts you care about. The first two levels open automatically. Strings, numbers and true, false or null values are colour coded in the same way as the code view.
The tree is most helpful when you are exploring an unfamiliar API response, checking whether a field exists in every item of a list, or explaining the shape of some data to a colleague. Documents with more than 5,000 values are shown in the code view only, to keep the page responsive.
Privacy and large files
Many online JSON tools send whatever you paste to a server. This one does not. Parsing, formatting, validation and the tree view all run in JavaScript inside your browser, and nothing is stored or logged. That makes it suitable for API responses that contain customer details, access logs, configuration with internal hostnames, or anything covered by a confidentiality agreement. Even so, remove passwords, API keys and tokens before sharing JSON with anyone else.
There is no fixed size limit. Files of several megabytes format comfortably on a modern laptop, although the live check and syntax colouring may take a moment on older phones. For very large output, colouring is switched off automatically so the page stays quick, and you can always download the result rather than scrolling through it on screen.
Examples you can copy
Invalid JSON and the fixed version
Invalid:
{
name: 'Make It Flow', // unquoted key, single quotes, comment
"tools": ["json", "base64",],
}
Valid:
{
"name": "Make It Flow",
"tools": ["json", "base64"]
}
The same data formatted and minified
Formatted (2 spaces):
{
"city": "Leeds",
"open": true,
"rating": null
}
Minified:
{"city":"Leeds","open":true,"rating":null}
Common mistakes to avoid
Fixing only the first error
One mistake can hide another. After fixing the reported problem, check the result again until it says the JSON is valid.
Trusting the error position too literally
The parser reports where it noticed the problem. A missing comma or bracket is often just before that point, at the end of the previous line.
Pasting smart quotes
Word processors and some chat apps turn straight quotes into curly ones. JSON only accepts straight double quotes.
Storing long IDs as numbers
Integers above 9,007,199,254,740,991 lose precision in JavaScript. Send large IDs as strings to keep them exact.
Leaving secrets in shared JSON
Formatting makes data easier to read for everyone. Remove API keys, tokens and personal data before sharing a file or screenshot.
Frequently asked questions
No. Formatting and validation run in JavaScript in your browser, so API responses, config files and customer data never leave your device.
JSON is stricter than JavaScript. It needs double quotes around every key and string, and it does not allow comments, trailing commas, single quotes or values such as undefined and NaN.
Validating checks whether the text follows the JSON rules. Formatting changes only the whitespace to make valid JSON easier to read. JSON has to be valid before it can be formatted.
No. It tells you exactly where each problem is and what is wrong, but it does not guess at fixes, because an automatic guess could silently change your data.
It changes the order of properties inside objects, which JSON treats as unimportant. Array order is never changed. If a system relies on property order, do not sort.
Not as a whole file, because each line is a separate JSON value. Paste one line at a time to format and check it.
Yes. JSON-LD is ordinary JSON, so you can format and validate it here. To check the schema.org types and properties themselves, use a schema validator as well.
JavaScript stores numbers as 64-bit floating point. Very large integers and some long decimals can change slightly when parsed. The tool warns you when it detects integers that are too large.
Once the page has loaded, formatting and validation work without a connection, because everything happens in your browser.
Learn more
- Structured Data for Small Businesses: What Still Works in 2026 Which schema markup still earns rich results in 2026: Organization, LocalBusiness and Article examples, plus what happened to FAQ and HowTo rich results.
- Automate Website Audits: Lighthouse CI, PageSpeed API, Webhooks How to run website audits automatically on every deploy and on a schedule with Lighthouse CI, the PageSpeed Insights API, audit APIs and signed webhooks.
- How to Format JSON and Fix Common JSON Validation Errors How to format JSON so it's readable, validate it, and fix the most common JSON errors: trailing commas, single quotes, comments, unescaped characters and more.
- LLM Evaluation Workflow: Tracking Regressions on Every Change An LLM evaluation workflow for AI product teams: versioned test sets, evals on every change, regression thresholds, human review and a clear release gate.
- Support Ticket Triage and Release Notes: A Workflow for Software Companies A support ticket triage and release notes workflow for software teams: consistent tagging, urgent escalation, linked bugs, drafted notes and customer follow-up.
- JSON vs YAML: Differences, When to Use Each and Common Pitfalls JSON vs YAML compared: syntax, comments, data types, where each is used, the YAML 1.1 yes/no trap, indentation errors and how to convert between them safely.
Free website audit
See how your site scores, free
Speed, SEO, DNS, email (SPF/DKIM/DMARC) and security in one scan, with a prioritised fix list.