Skip to main content
Developer Tools

JSON Formatter

Format, minify, validate, and sort JSON in your browser

0 chars · 0 lines
0 chars · 0 lines

How to Use

  1. Paste your JSON. Drop or paste any JSON payload into the input pane. The tool handles deeply nested objects, arrays, escaped strings, and Unicode characters.
  2. Pick an action. Format pretty-prints with your chosen indent (2 or 4 spaces). Minify strips whitespace. Validate parses without rewriting. Sort keys recursively alphabetizes object keys.
  3. Copy the result. Click the output pane’s copy button or copy any text directly. Errors appear inline with the line and column where parsing failed.

Why Use This Tool

  • All parsing happens in your browser using JavaScript’s native JSON engine — same parser the V8 runtime uses, so behavior matches Node and Chrome exactly.
  • Safe for sensitive payloads. API responses, JWT inner data, config files, and customer data never leave your device. Open DevTools → Network to verify.
  • Line-aware error messages tell you exactly which line and column broke the parse — no more searching through walls of JSON for a missing comma.
  • Sort-keys-recursive option produces canonical JSON, useful for diffing payloads or generating consistent hashes.
  • Indent selector (2 or 4 spaces) matches whatever convention your team uses.

Frequently Asked Questions

What’s the largest JSON I can format?

The browser’s JSON parser handles tens of megabytes comfortably on modern devices. Performance starts to degrade past ~50 MB because the entire object graph lives in browser memory. For multi-gigabyte JSON streams, use a streaming parser (jq, ijson) instead.

Why does formatting fail with “Unexpected token”?

The JSON parser is strict — it follows RFC 8259. Common causes: trailing commas after the last element of an object/array, single quotes instead of double, unquoted keys, or comments (JSON does not allow comments). The error message includes the line/column of the failure so you can locate it.

Does Sort Keys work on nested objects?

Yes. Sort Keys recursively visits every nested object and alphabetizes its keys. Arrays are not sorted (they are order-significant in JSON). Useful for producing canonical JSON for diffing, hashing, or version-controlling configuration.

Can I validate without reformatting?

Yes. The Validate button parses without rewriting. It reports either “Valid JSON ✓” with the byte size and key count, or the precise parse error. Use this when you want to keep the original whitespace/order but verify syntax.

Does this tool send my JSON to a server?

No. The formatter runs entirely in your browser. Open DevTools → Network and click any action — zero outgoing requests. Your API responses, JWT payloads, and config files never leave your device. This makes it safe for confidential data that other online formatters would log.

How do I handle JSON with comments (JSONC) or trailing commas?

Strict JSON does not allow either. To pre-strip comments and trailing commas, use a JSONC pre-processor like the VS Code jsonc-parser package, or convert via jq -e '.'. We may add a JSONC mode in a future update if there’s demand.

Related Tools