Developer Utilities · Free tool
JSON Formatter
Paste JSON to beautify, validate, and minify with clear error messages, all in your browser without sign-up—free instant tool for developers.
Advertisement
What it does
A no-fuss JSON formatter: paste any JSON, get it pretty-printed, minified, or validated with a clear error message. It runs entirely in your browser — your data never leaves the tab, which matters when you’re pasting real API responses or internal payloads.
Use Format when reading responses from an API, Minify when embedding JSON in a config file or URL, and Validate when you’re sanity-checking a payload before sending it. Error messages show the first thing JavaScript’s built-in parser complains about — usually a missing comma, an unquoted key, or a trailing comma.
Embed this tool on your siteShow snippetHide
Paste this snippet into any page. Loads on-demand (lazy), no tracking scripts, and sized to most dashboards. Replace the height to fit your layout.
<iframe src="https://freetoolarena.com/embed/json-formatter" width="100%" height="720" frameborder="0" loading="lazy" title="JSON Formatter" style="border:1px solid #e2e8f0;border-radius:12px;max-width:720px;"></iframe>Example input & output
Input
{"user":"ada","roles":["admin","editor"],"active":true}Output
{
"user": "ada",
"roles": [
"admin",
"editor"
],
"active": true
}Formatted with 2-space indent. Minify collapses the same structure back to a single line.
How to use it
- Paste JSON (valid or not) into the input box.
- Click Format for pretty-printed output with 2 or 4-space indent.
- Click Minify to strip whitespace for config files or URLs.
- Click Validate just to confirm structure without changing output.
How it works
Key takeaways
JSON.parseonly catches SYNTAX errors. A typo’d field name (userIdvsuser_id) parses fine but breaks at the API. Use a JSON Schema validator for shape checking.- Strict JSON (RFC 8259) has no comments, no trailing commas, and double-quoted keys only. JSON5 relaxes all three; JSONC adds only comments.
- Single-quoted strings are illegal in strict JSON. They’re the most common source of “Unexpected token” parse errors in copy-pasted JSON.
- For files over 100MB, use streaming parsers (jq, ijson in Python, JSONStream in Node) instead of loading the whole document into memory.
Uses the browser’s native JSON.parse(input) → format with JSON.stringify(parsed, null, 2). No data ever crosses the network. The parser used is the same v8 / SpiderMonkey / JavaScriptCore engine your browser ships with — standards-compliant per RFC 8259.
Advanced: strict JSON vs JSON5 vs JSONC
RFC 8259 strict JSON: keys quoted with double quotes, no comments, no trailing commas. JSON5 (used in Babel, RollupJS configs): allows unquoted keys, single quotes, comments, trailing commas. JSONC (used in VS Code settings, tsconfig.json): JSON with line and block comments only. APIs typically require strict JSON; config files often use JSON5 / JSONC. This tool uses strict; for JSON5 input, strip comments and convert single quotes first. See the JSON glossary entry.
How this compares to alternatives
vs jq: jq is the gold standard CLI for JSON manipulation; this tool is faster for one-off pretty-print and validation. vs jsonlint.com / jsonformatter.org: those send your data to their server. We don’t. vs VS Code “Format Document”: same result for valid JSON; this is faster when you don’t want to open the editor or paste into a file. vs json-schema validator: schema validation needs a separate tool; this only validates syntax.
Common mistakes when using this tool
- Pasting JSON5 / JSONC and getting parse errors. Trailing commas, single quotes, and comments aren’t valid in strict JSON. Strip them first.
- Trusting the format on truncated input. If you copied a fragment (missing closing brace), the formatter will report parse error, not format the partial. Don’t guess; copy the full payload.
- Using format output where minify is needed. Embedding pretty-printed JSON in a URL parameter or env var produces broken systems. Use Minify for those.
- Assuming this catches semantic errors. JSON.parse only catches SYNTAX errors. A typo like
userIdvsuser_idparses fine but breaks at the API. Use a JSON Schema validator for shape checking.
Learn more about JSON
- JSON syntax rules — the 6 hard rules of strict JSON, with the most common parser errors and how to fix them.
- JSON vs JSON5 vs JSONC — what each format allows, where each shows up, and which to use for configs vs APIs.
- JSON Schema explained — declarative validation, draft versions, and how it complements OpenAPI.
- API glossary — how JSON fits into REST and GraphQL APIs, and the difference between transport and contract.
When to use this tool
- You want to read/debug JSON without sending it to an unknown third-party site.
- You need a fast validator that tells you where the syntax error is.
- You want the output to use 2 vs 4-space indent and keep keys in insertion order.
When not to use it
- You need schema validation (JSON Schema / OpenAPI) — use a schema validator.
- You need a JSON diff — use a diff tool.
- You need JSON5 or JSONC (with comments) — this tool uses strict JSON.
Common use cases
- Reading a raw API response that came back on one line.
- Minifying a config payload before pasting into a URL or env var.
- Finding the exact character where a JSON parser is failing.
- Sharing a clean snippet in a code review or bug report.
Frequently asked questions
- Does my JSON get sent anywhere?
- No. The tool uses the browser's built-in JSON.parse and JSON.stringify. You can paste production payloads and secrets safely — nothing leaves the tab.
- Why does the error say 'Unexpected token'?
- Usually a missing comma between fields, a trailing comma after the last field, a single-quoted string, or an unquoted key. The column number in the error points at the offending character.
- What's the difference between JSON and JSON5?
- JSON (RFC 8259) is the strict standard: keys quoted with double-quotes, no comments, no trailing commas, no single-quoted strings. JSON5 is a superset that adds: unquoted keys, single-quoted strings, comments (// and /* */), trailing commas, and a few other conveniences. Most APIs require strict JSON. JSON5 is common in config files (Babel, ESLint accept JSONC). This tool uses strict JSON; for JSON5 input, strip comments and convert quotes first.
- How do I escape special characters in JSON strings?
- Inside a JSON string: use \" for double-quote, \\ for backslash, \n for newline, \t for tab, \u0000 for any Unicode codepoint by hex. Forward slashes don't need escaping but are sometimes escaped as \/ for HTML safety. Single quotes don't need escaping (they're not special in JSON). Avoid raw control characters (ASCII 0-31) — they must be encoded as \uXXXX or named escapes.
- Should I minify JSON in production?
- For HTTP responses: minify if you control both ends (gzip/brotli compresses both versions similarly, but minified is smaller before compression). For config files: keep formatted for human editing; minify only when embedding JSON inside a URL, env var, or a single-line shell command. For databases: most JSON columns store unformatted internally regardless; the document size after compression is what matters. Modern HTTP/2 and Brotli reduce the practical difference; readability often wins.
- What's the largest JSON I can format here?
- Browser-dependent but typically up to 50-100MB before performance degrades. Chrome and Firefox handle 10-20MB JSON in under a second; 100MB takes 5-15 seconds and may freeze the tab briefly during JSON.parse. For files over 100MB, use streaming parsers (jq, ijson in Python, JSONStream in Node) instead of loading into memory. Most API responses are well under 1MB; this tool handles them instantly.
- Is this JSON formatter safe for sensitive data?
- Yes. The tool runs entirely in your browser using native JSON.parse and JSON.stringify — no data crosses the network. You can verify by opening DevTools Network tab while pasting; you'll see zero requests fire. You can also disconnect from the internet and the formatter still works. Safe to paste: production API responses, secrets, JWTs, database export samples, customer data. Note: this is different from many free 'JSON validator' sites which send your data to their server (often logging it for analytics or training data). Always check a tool's network behavior before pasting sensitive content. For an extra-paranoid workflow: download the page once, then run it offline — confirms zero external dependencies at the network level.
- How do I format JSON in the command line manually?
- macOS/Linux: 'cat data.json | python -m json.tool' (built-in Python; works on macOS by default). 'jq .' is the most powerful — install with 'brew install jq' (Mac) or 'apt install jq' (Linux); pretty-prints with '.' filter, lets you query: 'jq .users[0].name data.json'. Node.js: 'cat data.json | node -e "console.log(JSON.stringify(JSON.parse(require(\'fs\').readFileSync(0)), null, 2))"'. PowerShell (Windows): 'Get-Content data.json | ConvertFrom-Json | ConvertTo-Json'. For huge files (>100MB), use streaming: 'jq -c . huge.json' (compact, line-delimited) avoids loading the whole tree. Quick validation only: 'jq -e . file.json && echo VALID || echo INVALID'.
- What's the best way to validate JSON structure?
- Two layers: SYNTAX validation (catches parse errors) and SCHEMA validation (catches shape errors like missing fields or wrong types). Syntax: any JSON.parse-based tool catches this. Schema: use JSON Schema (industry standard) — define expected shape in a schema file, then validate with Ajv (Node), jsonschema (Python), or NJsonSchema (.NET). Example schema: {type: 'object', properties: {id: {type: 'integer'}, email: {type: 'string', format: 'email'}}, required: ['id', 'email']}. Tools: VS Code with the 'JSON Schema' extension auto-validates as you type if you include $schema. APIs: include schema in OpenAPI spec; clients auto-validate. Quick alternative: TypeScript types + a validator like Zod, io-ts, or yup — better DX and catches the same bugs without writing schema separately.
See how this compares
Advertisement
Learn more
Guides about this topic
- Developers & Technical · GuideHow to Learn Coding FastPick one language, build small projects, and maintain a daily habit. Learn coding fast online with our free instant plan, no sign-up required in seconds.
- Developers & Technical · GuideHow to encode and decode Base64Understand the 3-to-4 mechanic and 33% overhead for standard, URL-safe, and MIME Base64. Free online reference to avoid common mistakes, no download needed.
- Developers & Technical · GuideHow to use CSS clamp()clamp() syntax, the preferred-value math, fluid typography without media queries, container query units, accessibility, browser support.
- Using Our Tools · GuideHow to generate QR codesMake QR codes for URLs, WiFi, vCard, or text. Learn error correction and sizing, then generate your QR code online free with no sign-up in seconds.
- Using Our Tools · GuideHow to create a strong passwordGenerate a strong password instantly online for free. Build high-entropy passphrases following NIST 2026 rules with no download needed.
- Design & Media · GuideHow to choose a color paletteBuild accessible color palettes using HSL theory, monochromatic to triadic schemes, WCAG contrast checks, and dark mode tips. Free, no-download guide.
Explore more developer utilities tools
- Port Number LookupSearch over 140 well-known TCP and UDP ports by number or service name. Free online reference tool with no sign-up, covering web, mail, DNS, and more.
- Test Credit Card NumbersReference table of canonical test card numbers from Stripe, Adyen, and Braintree sandbox docs. Plus Luhn validator + network detector.
- IPv6 Expander & ShortenerFormat IPv6 addresses to canonical form, handling zone IDs and prefixes, instantly online—free tool with no registration required.
- Htpasswd GeneratorCreate .htpasswd lines for Apache or nginx basic auth with browser-only SHA hashing instantly. Includes config snippets and a free online tool with no registration.
- Chmod CalculatorCalculate Unix file permissions: octal (755, 644) ↔ symbolic (rwxr-xr-x) ↔ rwx checkboxes. Covers setuid, setgid, sticky bit. With presets.
- Excel Formula ExplainerPaste any formula and get a plain-English breakdown of 60+ functions online free—no sign-up required, in your browser.