Quick answer
To format JSON, paste it into the Input JSON box, choose the indent (2 spaces, 4 spaces or tab) and click Beautify. Click Minify to remove all whitespace, Validate to check the syntax (you will see "✓ Valid JSON" or an error with its line and column), or Sort keys to order object keys alphabetically. Copy or download the result. Your data is processed in your browser and never sent anywhere.
- Actions:
- Beautify, minify, validate, sort keys
- Indentation:
- 2 spaces, 4 spaces or tab
- Errors:
- Message with line and column
- Sort keys:
- Alphabetical, recursive through nested objects
- Output:
- Copy or download
- Standards:
- Strict JSON (RFC 8259)
- Upload needed:
- No – runs in your browser
- Price:
- Free
JSON (JavaScript Object Notation) is the language of modern data exchange. APIs return it, configuration files are written in it, databases store it, mobile apps send it and logs record it. But JSON straight from an API or a log is often one enormous line of text, impossible to read, and hand-edited JSON breaks easily: a single missing comma, an extra comma at the end of a list or a quote in the wrong style makes the whole document invalid.
Our JSON formatter and validator solves both problems. Beautify re-indents JSON so every object and array sits on its own lines with consistent indentation — 2 spaces, 4 spaces or tabs, whichever your team prefers. Validate checks that the JSON follows the standard and, when it does not, tells you what is wrong and exactly where, by line and column. Minify strips all unnecessary whitespace for the smallest possible payload. Sort keys orders every object's keys alphabetically, which makes large documents easier to scan and two versions easier to compare.
Because JSON often contains API keys, tokens, customer records and internal configuration, the formatter runs entirely in your browser. Nothing you paste is uploaded or logged.
How to format and validate JSON – step by step
- 1 Paste your JSONCopy JSON from an API response, file, log or code and paste it into Input JSON.
- 2 Choose the indentSelect 2 spaces, 4 spaces or tab.
- 3 Beautify or validateClick Beautify to format, or Validate to check the syntax.
- 4 Fix any errorsIf an error appears, go to the line and column shown and correct the problem.
- 5 Minify, sort or copyMinify for production, sort keys for comparison, then copy or download the result.
Why use this JSON formatter?
Beautify
Clean, consistent indentation in one click.
Validate with locations
Errors shown with line and column.
Minify
Smallest payload for APIs and storage.
Sort keys
Alphabetical keys at every level.
Flexible indentation
2 spaces, 4 spaces or tabs.
Private
Runs locally; sensitive data stays on your device.
The most common JSON errors
| Error | Wrong | Right |
|---|---|---|
| Trailing comma | {"a": 1, "b": 2,} | {"a": 1, "b": 2} |
| Single quotes | {'name': 'Rafi'} | {"name": "Rafi"} |
| Unquoted keys | {name: "Rafi"} | {"name": "Rafi"} |
| Missing comma | {"a": 1 "b": 2} | {"a": 1, "b": 2} |
| Comments | {"a": 1 // note} | JSON does not allow comments |
| Special values | {"x": undefined, "y": NaN} | Use null or a number |
| Unescaped quotes | {"q": "He said "hi""} | {"q": "He said \"hi\""} |
Beautify vs. minify
Beautified JSON is for humans: easy to read, review in code reviews and edit by hand. Minified JSON is for machines: it removes spaces and line breaks, typically cutting size by 10–30%, which matters for API responses, mobile apps and storage. The data is identical in both — only whitespace changes. Keep configuration files and examples beautified in your repository, and let your server or build process send minified JSON.
2 spaces, 4 spaces or tabs?
All three are valid; it is a matter of convention. Two spaces are the most common in JavaScript and web projects and keep deeply nested data compact. Four spaces are common in Python projects and some style guides. Tabs let each developer choose their display width. Pick the style your project already uses so diffs stay clean.
Why sort keys?
JSON objects are unordered by definition, so sorting keys does not change the meaning. It does make large objects easier to read and makes two versions of a document easier to compare line by line — for example to see what changed between two API responses or configuration files. Sorting is applied recursively to every nested object; array order is kept, because order in arrays is meaningful.
Working with API responses
When debugging an API, paste the raw response here to see its structure clearly, check field names and spot unexpected nulls or types. If the response contains Base64-encoded data or a JWT, decode it with our Base64 tool. To convert JSON for systems that need XML, use JSON to XML; for the reverse, XML to JSON. When an API needs an encoded value in a URL, use the URL Encoder.
JSON in SEO and websites
Websites use JSON-LD to describe content to search engines — products, articles, FAQs, organisations. Invalid JSON-LD is silently ignored by Google, so validate any structured data you write by hand here, or generate it correctly with our Schema Generator. Web app manifests and many configuration files for hosting platforms are JSON too.
JSON data types in brief
JSON has only six kinds of values, which makes it simple to learn. Strings are text in double quotes, with special characters escaped by a backslash. Numbers are written without quotes and may be negative or decimal, but not hexadecimal or with leading zeros. Booleans are true or false in lowercase. null represents an empty value. Objects are sets of key–value pairs inside curly braces, with keys always in double quotes. Arrays are ordered lists inside square brackets. Dates have no special type — they are usually stored as strings in ISO format such as "2026-11-22T10:30:00Z". Knowing these rules makes most validation errors obvious as soon as you see the highlighted position.
Reading JSON more easily
Beautified JSON is easier to read, but very deep structures can still be hard to follow. A few habits help: collapse what you do not need in your code editor, sort keys so related fields appear in predictable places, and look at one nested level at a time. When you only need a few values from a large response, search for the key name in the formatted output. When explaining an API response to a colleague, paste a formatted, trimmed example rather than the whole payload.
Large JSON files
The formatter handles files of several megabytes in modern browsers. For very large files (tens of megabytes), a text editor or command-line tool such as jq is faster: jq . file.json beautifies and jq -c . file.json minifies. Python's python -m json.tool file.json also formats and validates.
Privacy
JSON frequently contains secrets: API keys, access tokens, passwords in config files, customer names and order details. Pasting it into an online formatter that sends data to a server is a real security risk. This formatter uses your browser's built-in JSON parser and never transmits your data. Still, it is good practice to rotate any key you accidentally share anywhere.
Troubleshooting
- "Unexpected token". Usually a trailing comma, a single quote or a comment; check the line and column shown.
- "Unexpected end of JSON input". The JSON is cut off — a bracket or brace is missing at the end.
- Numbers lose precision. Very large integers (over about 9 quadrillion) cannot be represented exactly in JavaScript; store them as strings.
- Keys are in a different order. Sort keys reorders them; the data is unchanged.
Frequently asked questions
How do I format JSON?
Paste it into the input box and click Beautify.
How do I validate JSON?
Click Validate. You will see "✓ Valid JSON" or the error with its line and column.
What does minify JSON mean?
Removing all unnecessary whitespace to make the JSON as small as possible.
Why is my JSON invalid?
Common causes are trailing commas, single quotes, unquoted keys and comments.
Can JSON contain comments?
No. Standard JSON does not allow comments.
Does sorting keys change my data?
No. Object key order has no meaning in JSON; arrays keep their order.
Is my JSON uploaded?
No. Everything runs in your browser.
Can I download the formatted JSON?
Yes. Click Download.
What indentation should I use?
Two spaces is most common; use whatever your project uses.
Can it handle large files?
Yes, files of several megabytes. For huge files, use jq or a text editor.
Is the JSON formatter free?
Yes. No sign-up and no limits.
Can I format JSON on my phone?
Yes. Paste JSON into the box on any mobile browser.
What is the difference between JSON and a JavaScript object?
JSON is a strict text format: keys need double quotes, and comments, functions and trailing commas are not allowed.
Does it support Unicode?
Yes. Bengali, emoji and all other characters are kept.
Last updated November 27, 2026 · Written and tested by the SmallEasyTools team.