Skip to content
OddsockLocal
Local
Source text
{
  "color": "red",
  "count": 2
}
1 wordsRuns in this browser. Nothing is uploaded.

How to use

  1. Paste JSON into Source text.
  2. Set Indentation to 2 for the usual pretty form, or to 4 or 8 for a wider indent.
  3. Set Indentation to 0 when you want the compact string.
  4. Copy the result. A syntax error names the line and column and leaves the source unchanged.

What is JSON formatter?

Pretty-print is for a person reading a payload. Minify is for the bytes you send. JSON formatter parses the document and writes it back with the indent you pick: 0, 2, 4, or 8 spaces. Indent 2 puts each key on its own line and a blank before each value. Indent 0 writes the compact form, with no space after colons or commas.

Read more

The formatter checks that the text is JSON before it prints anything. A trailing comma or a missing comma stops it with the parser's line and column, and nothing is rewritten. Key order is preserved. Alphabetizing keys is a different page, and you want that when the next step is a diff. This page only changes whitespace.

Use cases

  • A reviewer pastes a one-line API response and reads it at indent 2.
  • A mobile client log is expanded to indent 4 so nested objects line up with the team's style.
  • Someone about to attach a payload sets indent to 0 and compares the length with the pretty form.
  • A fixture in a pull request is reformatted at indent 2 so the review shows data changes.
  • A broken snippet is pasted to learn the column of the first syntax error before it is repaired.

Two spaces on a color object

{"color":"red","count":2}. Indentation set to 2. Set it to 0 for the compact line, or to 4 for a wider indent.

Indent 2: { "color": "red", "count": 2 } That is 34 bytes. Indent 0 is {"color":"red","count":2}, 25 bytes. Indent 4 is 38 bytes. Nine bytes separate the reading form from the compact form.

Why use Oddsock

The indent control is the whole decision: two spaces to read, zero spaces when the byte count matters.

Related tools

Using this tool

For {"color":"red","count":2}, indent 2 is 34 bytes and indent 0 is 25 bytes. The nine bytes are the newlines and the spaces around colons.