JSON Formatter
Pretty-print, minify, and alphabetically sort JSON payloads locally inside a dedicated Web Worker.
Local Workspace (json-utility)
How to Use JSON Formatter
- 1Paste your raw or minified JSON payload into the Input JSON pane (or click Load Sample).
- 2Choose Format / Beautify (with 2 Spaces, 4 Spaces, or Tab indentation) or Minify, and check Sort Keys (A-Z) if you want canonical key ordering.
- 3Copy the formatted JSON to your clipboard or click Download .json to save a sanitized local file.
Technical Specifications & Guardrails
- Off-main-thread parsing and serialization in json.worker.ts with a 10-second watchdog timeout
- Configurable indentation (2 spaces, 4 spaces, 1 tab) and single-line Minify mode
- Recursive alphabetical object key sorting for deterministic Git diffs
- Live structural telemetry reporting total Object Keys, Max Depth, and Input/Output byte sizes
Practical Example: Normalizing Minified API Responses for Git Diffs
- Sample Input
- A single-line 450 KB REST API response with randomly ordered object keys across nested records.
- Verified Local Output
- Formatted with 2-space indentation and recursive alphabetical key sorting so two API snapshots can be compared line by line.
Operational Limits & Browser Guardrails
Processes JSON documents up to 10 MB locally (offloading payloads above 50 KB to json.worker.ts with a 10-second timeout). Follows strict RFC 8259 JSON serialization; JavaScript-only values such as undefined, functions, or BigInt literals are not valid JSON.
Frequently Asked Questions
Is my JSON payload sent to an external API when formatting?
Never. Parsing and formatting happen entirely inside your browser's local memory and background Web Worker (`json.worker.ts`).
Does Sort Keys (A-Z) change the order of items inside JSON arrays?
No. Recursive key sorting reorders object property keys alphabetically (`a.localeCompare(b)`) at every nesting level while keeping array element order 100% intact.
When should I use Minify mode?
Minify mode strips all insignificant whitespace and line breaks to produce the smallest possible UTF-8 byte payload for HTTP bodies, environment variables, or database columns.