JSON Formatter
Format, validate and beautify JSON directly in your browser.
Most JSON you meet in the wild is minified - a single dense line with no whitespace, built to travel over the wire rather than be read by a human. Config files, API responses, package manifests and webhook payloads all arrive this way. This formatter takes that compressed text and lays it out with consistent indentation, so the structure is visible at a glance and nested data stops hiding in a wall of characters.
Paste JSON into the input box, pick 2-space, 4-space or tab indentation, and hit Format. The output renders with syntax highlighting and line numbers, which makes tracing a nested object or an array of records far less painful. Minify does the reverse: it collapses formatted JSON back to a single compact line, handy right before you paste a payload into a curl command or an API client.
Everything runs locally. The JSON is parsed and re-serialized inside your browser using the native JSON.parse engine, and nothing is ever uploaded. If the input is invalid, you get the exact line and column of the first problem instead of a silent failure - exactly what you want when you are debugging a response body at two in the morning.
Features
- Format messy, minified JSON with 2-space, 4-space or tab indentation in one click.
- Minify formatted JSON back to a single compact line for curl commands, logs or API clients.
- Validate JSON as you work and get the exact line and column of the first error.
- Syntax highlighting and line numbers make nested structures readable at a glance.
- Copy the result to your clipboard or download it as a .json file, ready for a project.
- Everything runs in your browser - no uploads, no accounts, no data leaves your device.
- Handles large payloads: parsing is a single native pass, so typical configs and API responses format instantly.
- Press Ctrl+Enter (Cmd+Enter on Mac) to format without reaching for the mouse.
How to Use
- 1
Paste your JSON
Paste or type JSON into the input area. The tool accepts text from anywhere - a response body, a config file or a line of logs - and empty or clearly broken input is reported inline.
- 2
Choose an indentation
Pick 2 spaces, 4 spaces or tabs from the selector. The output re-renders to match, so you can compare styles on your own payload before committing to one.
- 3
Format or minify
Press Format to pretty-print with line breaks and indentation, or Minify to collapse everything into a single line. Ctrl+Enter runs Format as a keyboard shortcut.
- 4
Read the output
Syntax highlighting and line numbers make it easy to trace nested objects and long arrays. Select any slice of the output to copy just that part.
- 5
Copy or download
Use Copy to put the formatted JSON on your clipboard, or Download to save it as a .json file you can drop straight into a project.
Example
Minified JSON in
{"name":"Alice","age":30,"items":[1,2,3]}↓
{
"name": "Alice",
"age": 30,
"items": [
1,
2,
3
]
}Deeply nested payload
{"user":{"id":42,"profile":{"display_name":"dev","roles":["admin","maintainer"]},"settings":{"notifications":{"email":true,"push":false}}}}↓
{
"user": {
"id": 42,
"profile": {
"display_name": "dev",
"roles": [
"admin",
"maintainer"
]
},
"settings": {
"notifications": {
"email": true,
"push": false
}
}
}
}Escaped strings are preserved
{"url":"https://example.com/path?a=1&b=2","note":"Line 1\nLine 2","emoji":"😀"}↓
{
"url": "https://example.com/path?a=1&b=2",
"note": "Line 1\nLine 2",
"emoji": "😀"
}Common Problems
Trailing commas
JSON does not allow a comma after the last item in an object or array. It is a habit that carries over from JavaScript object literals, and this formatter will flag it with a line and column rather than silently dropping it.
Single quotes around strings
JSON strings must use double quotes. Single quotes are fine in JavaScript source but invalid in JSON, so 'name' needs to become "name" before the parser will accept the document.
Comments inside the data
JSON has no comment syntax. If a config file contains // or /* */ lines, they have to be removed before the document can be parsed - a common gotcha when moving from YAML or a JavaScript config object.
Unquoted keys
Object keys must be quoted. {name: "x"} is valid JavaScript but not valid JSON; it has to be written as {"name": "x"} to parse.
Duplicate keys
When a document repeats a key, the JSON specification allows parsers to keep the last occurrence. The formatter follows the standard parser behaviour, so it keeps the final value rather than erroring out.
Non-finite numbers
JSON only supports finite decimal numbers. Values like NaN, Infinity or 1e999 are not valid JSON and are reported as errors at the exact position where they appear.
Technical Details
The formatter parses input with the browser's native JSON.parse, which implements RFC 8259 and ECMA-404. That means it accepts exactly the grammar those specifications define - nothing more, nothing less.
Formatting re-serializes the parsed value with the chosen indentation using JSON.stringify(value, null, indent). Because the document is round-tripped through a real parser, the output is guaranteed valid JSON rather than a best-effort regex pass.
Validation reports the first syntactic error with a line and column. The position is computed from the character offset the parser reports, giving you a precise place to look instead of a generic "invalid JSON" message.
Everything runs client-side. The input is read and written in memory inside your browser tab, and no part of it is transmitted to a server - which is what makes the tool safe to use with sensitive payloads like tokens or internal configuration.
Large documents are handled in a single native pass: JSON.parse does not stream or chunk, so typical configuration files and API responses format in milliseconds. For extremely large files, the browser's memory limit is the only ceiling.
Minify is the inverse operation: it re-serializes the document with no whitespace between tokens, producing the compact form you see in HTTP request bodies and log lines.
Frequently Asked Questions
Is my JSON sent to a server?
No. Everything runs in your browser using the native JSON APIs. Your input never leaves the device, which makes the tool safe to use with sensitive payloads like API keys, tokens or internal configuration files.
Does the formatter fix invalid JSON?
No. When input is invalid, the tool reports the first error with a line and column. Auto-correcting JSON is unreliable - a comma here or a quote there can change the meaning of the data - so an honest error is safer than silently altering your payload.
What is the difference between Format and Minify?
Format pretty-prints the document with indentation and line breaks so the structure is readable. Minify collapses it back to a single compact line. Both run through the same parser, so neither one changes the data itself.
Can it handle large JSON files?
Yes, within the limits of your browser. Parsing is a single native pass, so config files and typical API responses format instantly. Extremely large documents are limited only by the browser's available memory.
Why are my strings showing escaped characters?
Some characters - newlines, tabs, quotes and Unicode outside the printable range - are stored escaped in the original JSON, and formatting preserves them exactly. The output is the same data, just laid out so it is easier to read.
2-space, 4-space or tabs - which should I use?
It is a style choice. Two-space indentation is common in the JavaScript ecosystem, four-space is popular in Python and Java, and tabs are required by some linters. Try each against your own payload and pick the one your team already uses.
Data & Privacy
Your data stays in your browser. Nothing is uploaded.
- Processing
- Local
- Upload
- None
- Server Storage
- None
- Account
- Not required
Related Tools
JSON Validator
Validate JSON and pinpoint the first error with a line, column and plain-English explanation.
JSON & Data
JSON Minifier
Compress formatted JSON into a single compact line and see exactly how many bytes you save.
JSON & Data
JSON Diff
Compare two JSON documents and see every added, removed or changed value with its exact path.
JSON & Data
JSON to CSV Converter
Convert a JSON array of objects into a CSV file with automatic headers and proper escaping.
JSON & Data
CSV to JSON Converter
Convert CSV files into a clean JSON array, with optional automatic type detection.
JSON & Data
JSON to TypeScript Converter
Generate TypeScript interfaces or type aliases from a JSON sample, with nested types inferred.
JSON & Data
Related Guides
How to Format JSON: Readable Output in the Browser, Editor or Terminal
Format minified JSON for readability with an online formatter, an editor shortcut, or a command-line tool like jq or python -m json.tool.
How to Validate JSON: Find the Exact Line and Column of a Syntax Error
Validate JSON syntax with the online validator, JSON.parse in JavaScript or json.loads in Python, and diagnose the most common parse errors.
JSON Syntax Guide: The Six Value Types and the Rules That Catch You
A complete walkthrough of JSON syntax: objects, arrays, strings, numbers, booleans and null, plus the edge cases that break real documents.
JSON vs YAML: Which Format Should You Use, and How Do You Convert?
JSON for data crossing system boundaries, YAML for configuration humans write. Compare syntax, footguns and how to convert between them losslessly.
Common JSON Errors: The Five Mistakes That Break Every Parse
The short list of JSON parse failures - trailing commas, unquoted keys, missing commas, comments and unbalanced braces - with symptom, cause and fix.