JSON Formatter
Pretty print minified JSON with 2 or 4 space indentation, sort keys, and minify it back.
Format JSON in one click
Paste minified or messy JSON and press Format (or ⌘⇧F). The formatter re-indents every object and array, puts each property on its own line and keeps the value types exactly as they were. Switch back to a single line with Minify whenever you need a compact payload again. The tree on the right stays in sync so you can verify the structure as you go.
Formatting options
- Indentation. Two spaces is the JavaScript and npm convention; four spaces matches many Python and Java code bases.
- Sort keys. Orders every object’s properties alphabetically, recursively. Sorted output gives stable diffs in Git and makes it easy to spot a missing field between two responses.
- Validation while you type. A syntax error is reported with its line and column and a plain-English message, so a stray trailing comma never becomes a mystery.
Like every tool on TheJSON, this runs entirely in your browser. Nothing you paste is uploaded, logged or stored on a server, so it is safe to use with API responses that contain tokens or customer data.
Frequently asked questions
What is the difference between formatting and beautifying JSON?
- Nothing. Both mean adding line breaks and indentation so the document is readable. TheJSON uses one engine for its formatter and beautifier pages.
Does formatting change my data?
- No. Only whitespace between tokens changes. Strings, numbers, booleans, null and the order of keys are preserved unless you explicitly choose Sort keys.
Should I use 2 or 4 spaces for JSON?
- Match the code base the file lives in. JavaScript and TypeScript projects almost always use 2 spaces; Python, Java and .NET projects often use 4. Either is valid JSON.