Skip to content
StringToJSON

Format

Beautify or minify JSON in one keystroke.

Paste a wall of compressed JSON and get an indented document you can read — or go the other way and strip every byte you do not need.

JSON

0 B

Formatted JSON

0 B

Output appears here.

Ready. Paste something above.

Everything runs locally in your browser — your data never leaves this page. Press⌘/Ctrl +Enter to run.

Formatting is a readability tool, not a data change

JSON is whitespace-insensitive between tokens. Indenting a document, collapsing it, or reordering its object keys produces text that parses to exactly the same value. That is what makes formatting safe to apply to anything — a production response, a lock file, a config you are about to commit.

Indentation options

  • 2 spaces — the web default: npm, Prettier, most API responses.
  • 4 spaces — common in Python, Java and .NET tooling.
  • Tab — smallest on disk of the readable options, and respects a reader's own width preference.
  • Minified — no whitespace at all. Use it for payloads on the wire, not for files in version control.

Sorting keys for clean diffs

Many APIs serialize object keys in whatever order their hash map happened to produce. Two responses with identical data can then produce a hundred-line diff. Enabling Sort keysnormalizes both sides so the diff only shows what genuinely changed.

How big a file can it handle?

The limit is your browser's memory, not a server quota. Documents in the low megabytes format without trouble. If you are working with something much larger, a streaming tool such asjq is a better fit than any browser-based formatter.

Common formatting errors

  • Trailing commas — legal in JavaScript literals, illegal in JSON.
  • Single-quoted keys or values — JSON requires double quotes.
  • Unquoted keys{name: "Ada"} is a JavaScript object, not JSON.
  • NaN / Infinity / undefined — none of these exist in the JSON grammar.

Each of these is reported with a line and column by the validator.

Formatting from the command line

# jq — the standard tool
jq . data.json                 # pretty-print
jq -c . data.json              # minify
jq -S . data.json              # sort keys

# Python, no install required
python -m json.tool data.json
python -m json.tool --compact data.json

# Node
node -e 'console.log(JSON.stringify(require("./data.json"), null, 2))'

Any of these work fine in a pipeline. A browser tool earns its place for the other half of the job — when the JSON is on your clipboard rather than in a file, when it is not valid yet and you need to find out why, or when you want to eyeball the structure before deciding what to do with it.

Minify for the wire, format for the repository

The two directions serve different readers. Minified JSON is for machines: an API response, a cache entry, a message on a queue. Stripping whitespace from a typical document removes roughly a fifth of its bytes, and on a high-traffic endpoint that is real bandwidth — though note that once gzip or brotli is in play, most of that saving is already being made for you, so minifying a compressed response is a smaller win than it looks.

Formatted JSON is for people and for version control. A minified file in a repository produces a single-line diff on every change, which makes review impossible and merges painful. Indent anything committed to git, and pair it with sorted keys if the file is generated, so the diff shows the change rather than a reshuffle.

Starting from something that is not JSON yet

If your input is escaped or stringified, format it after converting it: thestring to JSON converter unwraps the encoding and formats in the same pass. The same applies to XML and Base64 payloads — convert first, and the formatting comes with it.

Frequently asked questions

What indentation should I use?
Two spaces is the default in most JavaScript and web toolchains; four is common in Python and Java ecosystems. Pick whatever your repository already uses — a formatter that disagrees with your linter just creates diff noise.
Does minifying change the data?
No. Whitespace between tokens carries no meaning in JSON, so minifying only removes bytes. The parsed value is identical.
What does "sort keys" do?
It rewrites every object with its keys in alphabetical order, recursively. Object key order is not significant in JSON, so this is safe — and it makes two documents diffable when a server returns them in an unstable order.
Are comments supported?
No, and that is by design. JSON has no comment syntax. If your file has // or /* */ in it you are looking at JSONC or JSON5, which need a different parser.
Can I convert JSON to plain text?
Formatting already gives you readable plain text — indented JSON is just text you can paste anywhere. If you want the values without the JSON punctuation, JSON to CSV flattens an array of records into rows.