Format, validate and minify JSON in one place
JSON Formatter & Validator
Paste minified JSON or open a .json file and format it with clean, consistent indentation. Syntax is checked as you type, with the exact line, column and a plain-English fix for any error. Copy or download the result. Your data stays in your browser.
Tip: Ctrl + Enter runs Format JSON
Valid JSON
198 B1 linedepth 3Processed in your browser
What does a JSON formatter and validator do?
A JSON formatter takes valid JSON and rewrites it with one property or array item per line, indented to show how the data is nested. API responses, logs and config files often arrive minified on a single line or with mixed indentation. Formatted JSON is easier to read, review and diff, and it is what most style guides expect in a repository.
The validator half checks that your text is valid JSON as defined by RFC 8259 before anything is formatted. If something is wrong, the status above the editor shows the line and column of the error with a short explanation, and Go to error moves the cursor there. Formatting changes whitespace only, unless you choose to sort keys.
How to format and validate JSON online
- 1
Paste or open JSON
Paste an API response or config into the editor, press Open file to load a .json file, or drag a file onto the editor.
- 2
Check the status
The status shows Valid JSON, or the line and column of the first error with a suggested fix and a Go to error button.
- 3
Format or minify
Select 2 spaces, 4 spaces or tabs, tick Sort keys if you like, then press Format JSON or Minify.
- 4
Use the result
Copy the formatted JSON, download it as a file, or open the tree view to check nested values.
Everything you need for everyday JSON
- Live validation
- Syntax is checked on every edit. Errors are reported by line and column, highlighted in the editor and explained in plain English.
- Format and beautify
- Indent with 2 spaces, 4 spaces or tabs. Optionally sort object keys alphabetically for stable diffs and reviews.
- Minify
- Collapse formatted JSON back to a single line for request bodies, environment variables and fixtures, and see the bytes saved.
- Open and save files
- Open .json, .geojson and .har files from your device, or drop them on the editor. Download the result when you are done.
- Tree view
- Browse objects and arrays as collapsible branches with item counts, without changing your source text.
- Private by design
- Parsing, formatting and validation run in your browser. Your JSON is never sent to a server.
Formatting vs validating vs minifying
| Operation | What it does | Changes your text? |
|---|---|---|
| Validate | Checks the text follows JSON syntax and reports the first error | No |
| Format (beautify) | Adds indentation and line breaks to valid JSON | Whitespace only |
| Sort keys | Orders object properties alphabetically at every level | Property order |
| Minify | Removes all whitespace outside strings | Whitespace only |
Which indentation should you use?
| Style | Common in | Why choose it |
|---|---|---|
| 2 spaces | package.json, tsconfig.json, most JavaScript projects, Prettier default | Compact and the most widely used |
| 4 spaces | Python json.dumps examples, .NET and Java projects | Deep nesting is easier to scan |
| Tabs | Go projects, teams that set their own tab width | Each reader picks the visual width |
When to format JSON
- Reading API responses
- Paste a response body from your browser's network tab, curl or Postman and see its structure at a glance.
- Cleaning up config files
- Normalise indentation in package.json, tsconfig.json, composer.json or appsettings.json before committing.
- Stable diffs
- Format both versions the same way, and sort keys, so a code review shows only real changes.
- Docs and bug reports
- Paste readable JSON into a ticket, README or Slack message instead of a single long line.
Format JSON from the command line or code
The online formatter is quickest for one-off documents. For scripts and pipelines, these one-liners do the same job.
| Tool | Command |
|---|---|
| jq | jq . data.json |
| Python | python -m json.tool --indent 2 data.json |
| Node.js | node -e "console.log(JSON.stringify(require('./data.json'), null, 2))" |
| JavaScript | JSON.stringify(value, null, 2) |
| VS Code | Shift + Alt + F (Windows/Linux) or Shift + Option + F (macOS) |
What formatting can change
Formatting and minifying parse your JSON and write it back out, so the data stays the same but a few representation details can change. Duplicate property names collapse to the last value, integer-like keys such as "10" move ahead of other keys, and numbers beyond 9,007,199,254,740,991 can lose precision. Keep long numeric IDs as strings, and keep your original file when byte-for-byte output matters.
JSON Formatter & Validator FAQ
Does formatting also validate my JSON?
Yes. The text is parsed before it is formatted, and the Format button is disabled until the JSON is valid. Invalid input stays in the editor so you can fix it without losing anything.
How do I format a JSON API response?
Copy only the response body (not the headers) into the editor and press Format JSON. If the response starts with something like )]}' or a variable assignment, remove that prefix first.
Can I format a JSON file?
Yes. Press Open file, or drag the .json file onto the editor. The file is read by your browser, not uploaded. After formatting, press Download to save the formatted copy.
Why is the Format button disabled?
The JSON is not valid yet. The message above the editor shows the line, column and likely cause. Press Go to error, fix it, and the button becomes active.
Is this the same as JSONLint?
It does the same core job as JSONLint: it checks that JSON is valid and reports where it breaks. It also explains the likely cause of each error, formats and minifies the result, and does all of it in your browser.
Does the formatter change my data?
Only whitespace changes, unless you choose Sort keys. Values are not modified, although very large integers can lose precision because browsers store numbers as 64-bit floats.
What is the difference between a JSON formatter and a JSON beautifier?
There is none in practice. Formatter, beautifier, prettifier and pretty printer all mean adding indentation and line breaks to make JSON readable.
Can I format JSON that contains comments?
No. Comments are not valid in standard JSON, so the validator reports them as errors. Remove // and /* */ comments first. JSONC and JSON5 are different formats.
Is there a size limit?
There is no fixed limit, but very large files depend on your device's memory. Files of tens of megabytes usually work on a laptop. Files over 60 MB are refused to avoid freezing the tab.