JSON Formatter
JSON Formatter pretty-prints or minifies JSON in your browser. Paste an object, array, or API payload, parse it locally with JSON.parse, then copy output indented with 2 spaces, 4 spaces, or tabs, or minified to one line. Nothing is uploaded, stored in localStorage, or sent to a formatter API. Invalid JSON (trailing commas, comments, single quotes) is rejected so the copy stays RFC 8259.
Updated
The first job of this page is to turn messy or minified JSON into readable text, or the reverse, without a paste-bin. Invalid JSON — trailing commas, comments, single quotes — is rejected next to the input so the output stays RFC 8259 JSON you can paste into an API. Enable sort keys when you want alphabetical keys for a diff. Closing the tab drops the payload; we do not write it to localStorage.
Paste an object, array, or API response. Standard JSON only — no comments or trailing commas.
Output
Pretty-printed JSON will appear here.
How does the JSON Formatter work?
1. Paste JSON
Drop in an object, array, or JSON text — including typical copy from an API response. An India-first example is available from Load example.
2. Parse locally
The browser’s JSON.parse runs in this tab to check the text. Invalid JSON gets an error next to the input; we do not send the blob anywhere. Valid JSON is then reprinted from your original text, so big integers like 64-bit IDs, 1.50, and \u escapes are copied exactly as typed.
3. Pretty-print or minify
Use the toolbar to choose Pretty with a 2-space, 4-space, or tab indent, or a compact minified form. Enable sort keys if you want alphabetical keys for diffs.
4. Copy the result
When the JSON is valid, copy the formatted output. Closing the tab drops the payload.
Questions about JSON Formatter
- Does JSON Formatter upload my payload?
- No. Parsing and formatting run in the browser. There is no account and no server-side formatter. The text you paste stays in this tab until you clear it or close the page. We do not write it to localStorage. That is the same privacy rule as JWT Token Decrypt on this hub.
- Can JSON Formatter fix trailing commas?
- No. The tool formats standard JSON. Trailing commas, comments, and single quotes are rejected as invalid JSON, and the error appears next to the input rather than failing silently. If you need to accept JSON5 or JSONC, use an editor that documents that dialect. This page stays strict so the output is safe to paste into APIs that expect RFC 8259 JSON.
- Is the pretty-printed output stable for diffs?
- Pretty-print uses the indent you pick (2 spaces by default, 4 spaces, or tab) and keeps keys in the order you pasted them. Enable sort keys in the toolbar if you want sorted keys before you copy: keys are compared character by character (the same order as jq -S or Python’s sort_keys), so "10" sorts before "2" and uppercase before lowercase. Minify emits a single line. Neither mode reorders array items or rewrites values. For very large documents, prefer a local CLI; this page is meant for typical API payloads.
- What about very large JSON files?
- The page is meant for typical API payloads. Multi-megabyte documents may strain the tab; keep large jobs on your own machine with a local CLI. There is no upload size limit because nothing is uploaded — the limit is whatever your browser can parse in memory without becoming unresponsive.
- Does JSON Formatter validate against a schema?
- No. It only checks that the text is valid JSON and then reprints it. A green valid state means the parser accepted the document, not that the shape matches an OpenAPI or JSON Schema file. For schema checks, use a dedicated validator. This page is a formatter with a copy control.
- Can I choose a different indent, like tabs or four spaces?
- Yes. With Pretty selected, the Indent menu in the toolbar switches between 2 spaces (the default), 4 spaces, and Tab — the same widths JSON.stringify accepts, so the output matches what JSON.stringify(value, null, 4) or a tab indent gives you in code. Minify ignores the indent and collapses everything to one line. Every option is still valid JSON, and Sort keys works with any of them.
- What happens with very deeply nested JSON?
- Typical API payloads, which nest a few dozen levels at most, format without issue. The reprint and sort-keys steps walk the text with a loop rather than recursion, so depth alone no longer overflows the call stack; minify handles thousands of levels. Pretty-printing an extremely deep structure is different: every level adds indentation to every line below it, so tens of thousands of levels can exceed the browser’s maximum string length, and the page shows that error (RangeError: Invalid string length in V8-based browsers) next to the input instead of output. If you hit it, use Minify or a local CLI.
- Will JSON Formatter round big numbers like 64-bit IDs?
- No. JSON.parse only checks that the text is valid; pretty-print, minify, and sort keys then reprint your original text token by token. A JavaScript number cannot hold every integer above 9007199254740991, so tools that round-trip through JSON.parse and JSON.stringify turn 12345678901234567890 into 12345678901234567000. This page copies 12345678901234567890, 1.50, 1E5, and \u00e9 exactly as you typed them, including when keys are sorted.
- How does JSON Formatter treat duplicate keys?
- JSON does not define duplicate object keys, and most parsers, including the browser’s JSON.parse, keep the last value when the same key appears twice in one object. This formatter reprints your text instead of the parsed object, so a duplicate key is not flagged and not dropped: both entries stay in the output exactly as written. With sort keys on, duplicates stay next to each other in their original order. If you need to detect collisions, check the source in an editor that highlights duplicates.
What else can I open?
- JWT Token DecryptDecrypt a compact JWE locally with Web Crypto.
- CSS FormatterPretty-print or minify CSS locally in the browser.
- SQL FormatterPretty-print SQL queries locally — does not execute SQL.
- JSON ViewerExplore JSON as a collapsible tree with search and copyable JSONPath, in the browser.
- JSON Schema GeneratorGenerate a JSON Schema from a JSON sample in the browser — no upload.
- YAML FormatterPretty-print and validate YAML in the browser — keeps YAML as YAML, nothing uploaded.
These tools run in your browser. Page Utils does not store, upload, or write to localStorage the keys, tokens, or text you paste. Results are a convenience aid, not legal, tax, or security advice.