JSON Formatter and Minifier
Format, beautify or minify JSON. Keeps key order unless you sort keys, rejects duplicate keys, and points to the first syntax error.
Runs in your browser — your input is processed on this device and never uploaded.
Input
JSON to format. Maximum 8 MiB. Duplicate object keys are rejected.
Result
Results appear here.
About this tool
On this page
What is a JSON formatter?
A JSON formatter, also called a JSON beautifier or pretty printer, rewrites JSON with line breaks and indentation so a person can read it. APIs often send JSON on one long line because parsers ignore the whitespace, and a missing comma hides in the noise.
JSON itself is a text format for objects, arrays, strings, numbers, booleans and null. This tool pretty-prints or minifies it.
JSON formatter options
- JSON
- The document to format, up to 8 MiB.
- Indent
- Two spaces (the default), four spaces, or Minify for a compact single line.
- Sort keys
- Off by default, so object key order is kept. Turn it on to sort keys recursively when you want two payloads compared without order noise.
- Duplicate object keys are rejected instead of silently keeping the last value.
- Invalid JSON is refused with the line and column of the first problem. Formatted output is capped at 18 MiB.
Why pretty-print instead of reading one line
Minified JSON is fine on the wire and painful to review. You cannot see the nesting, you cannot tell which closing brace belongs where, and a truncated paste looks like valid JSON until something downstream fails.
Pretty-print with a stable indent and you can read the shape, copy a field, or drop the result into a diff. Minify again when you need the compact form for a request body or a config value.
Sorting keys is a separate job. Two objects that differ only in key order are equal to most programs and unequal in a text diff. Sorting makes the text match.
JSON formatter alternatives
JSON Validator is the sibling when you only need a yes or no plus a caret under the first syntax error. It uses the same parser. YAML Formatter and Validator takes the same JSON and gives it back as YAML.
jq, Python's json.tool and the format command in most editors do this work locally. Reach for those when the file is already on disk or part of a script. This page is for the JSON on your clipboard right now.
It does not check data against a JSON Schema. It only checks that the text is JSON.
Things to know about JSON formatting
RFC 8259 allows duplicate keys, and most libraries keep the last value without telling you. That hides mistakes such as a field pasted twice, so this tool treats a duplicate as an error.
Warning
Sorted keys are not a canonical form. The order is plain Unicode code-point order of the key strings, not the RFC 8785 JSON Canonicalization Scheme, so don't use the output as a signing input just because the keys came out sorted.
Browse
Find similar tools by category or tag.