JSON Formatter

Pretty-print JSON with 2 or 4 spaces, minify it to one line, and sort object keys. Your text never leaves your browser.

How do I pretty-print or minify a JSON string?

Paste JSON to pretty-print, minify and sort keys instantly.

Pretty, minify and sort keys

More text tools for developers

How this tool calculates

Worked example

Sorting and minifying {"b":1,"a":{"d":4,"c":[3,1,2]}} gives {"a":{"c":[3,1,2],"d":4},"b":1}. The array [3,1,2] keeps its order. This value comes straight from the tool's own formatting function.

Things to know before you use it

The full counting rules and the sources for service limits are on Methods and standards.

Frequently asked questions

How many spaces can I indent with?

In pretty mode you can choose 2 or 4 spaces. Two spaces is the default for GitHub and most config files; four spaces makes the nesting easier to see. The result re-renders the moment you press a button.

Does sorting keys change the values?

No. Key sorting only reorders object keys in ascending Unicode code point order. Array order and every value stay the same, so parsing the output gives identical data. It is handy for diffing two JSON documents.

Why do comments or trailing commas cause an error?

Comments, a comma after the last element and single quotes are JSON5, not standard JSON. This tool uses the standard JSON.parse, so it does not accept them. Use the reported position to fix that part into standard JSON.

Is my JSON sent to a server?

No. Everything runs in your browser. You can paste API responses or config files with sensitive data and nothing is sent or stored on a server.

More text tools