JSON Tools

JSON Formatter

Format raw JSON with indentation that is easier to scan, review, and share.

{
  "name": "Softkey Tools",
  "stack": [
    "Angular",
    "TypeScript",
    "SSR"
  ],
  "published": true
}

Understand the format

How JSON Formatter works

Formatting rewrites only the whitespace between JSON tokens, so you can read a compressed payload without changing a single value.

What JSON formatting actually changes

JSON is defined by RFC 8259 as a token grammar in which whitespace between tokens is insignificant. Newlines, spaces, and tabs that sit between a comma and the next key can be added or removed freely without altering the document that a parser produces. That is the entire basis of pretty-printing: the formatter parses the text into values and then serialises those values again with indentation.

Because the round trip goes through a parser, formatting is also an implicit correctness check. If the input cannot be parsed, there is nothing to re-serialise, and the tool reports the parser error instead of guessing at a repair. A formatter never fixes broken JSON; it either reprints valid JSON or tells you why the text is not valid.

When compact output is the right answer

Indented JSON is for humans: code review, incident tickets, and documentation. Compact JSON is for transport and storage, where every byte of indentation is paid for on each request. The difference is smaller than it looks once HTTP compression is applied, because gzip and brotli collapse repeated runs of spaces very effectively, but it still matters for large payloads, message queues, and log lines that must stay on one line.

One practical rule: store and transmit compact, review and diff pretty. If a fixture file is committed to a repository, indented output produces far more readable version-control diffs, so the reviewability argument usually wins there.

Step by step

How to use JSON Formatter

  1. Paste the raw payload into the JSON input box on the left.
  2. Choose Pretty for two-space indentation, or Compact to strip all insignificant whitespace.
  3. If a red banner appears, read the reported position and fix that syntax error first; the formatter cannot reprint text it cannot parse.
  4. Copy the formatted result from the output panel into your ticket, fixture, or editor.

Formatting runs entirely in your browser using the built-in JSON parser. The payload is never transmitted, logged, or stored.

Worked examples

JSON Formatter examples explained

Compact API response expanded for review

Input

{"id":1042,"paid":true,"items":[{"sku":"A-1","qty":2}],"note":null}

Result

{
  "id": 1042,
  "paid": true,
  "items": [
    {
      "sku": "A-1",
      "qty": 2
    }
  ],
  "note": null
}

Nothing was added or removed. The nesting is now visible, and it is obvious that "paid" is a boolean while "note" is an explicit null.

Indented fixture minified for a request body

Input

{
  "query": "status:open",
  "limit": 25
}

Result

{"query":"status:open","limit":25}

Compact mode is useful when a payload must travel inside a single log line, a shell argument, or an environment variable.

Reference

The six value types defined by the JSON grammar

The six value types defined by the JSON grammar
TypeExampleWhat to watch for
string"order-1042"Double quotes only. Control characters, quotes, and backslashes must be escaped.
number42, -3.5, 1.2e6No NaN, Infinity, hex, or leading zeros. Values beyond 2^53 lose precision in JavaScript.
booleantrue, falseLowercase only. "true" in quotes is a string, not a boolean.
nullnullDistinct from an absent key and from an empty string.
object{ "id": 1 }Keys must be quoted strings. Key order carries no meaning.
array[1, 2, 3]Ordered. Mixed types are legal but usually a schema smell.

Practical Guide

How teams use JSON Formatter

Common use cases

  • Normalise payloads before pasting them into code review comments or incident tickets.
  • Switch between pretty and compact output to compare transport size against readability.
  • Inspect deeply nested objects before copying an example into a test fixture.

Checks before trusting the result

  • Formatting does not repair broken JSON syntax; validate the payload first if parsing fails.
  • Escaped characters in strings are preserved literally, so copy the output rather than retyping it.
  • Confirm the structure is still what you expect before switching to compact mode.

Troubleshooting

Common mistakes and how to fix them

A trailing comma after the last element of an object or array.
JSON, unlike JavaScript object literals, forbids trailing commas. Remove the comma before the closing brace or bracket.
Very large integers such as 9007199254740993 come back changed.
JavaScript numbers are IEEE-754 doubles, so integers above 2^53 - 1 cannot round-trip. Transport those identifiers as strings.
Copying from a document editor introduces typographic quotes.
Replace curly quotes with straight double quotes. The same applies to non-breaking spaces pasted from web pages.

FAQ

JSON Formatter questions, answered

Does formatting change my data?

No. Only insignificant whitespace changes. Keys, values, types, and array order are preserved exactly, because the output is produced by re-serialising the parsed document.

Why does the formatter reorder nothing but my diff still looks different?

Object key order is preserved as it appeared in the input, but two systems may emit keys in different orders. Compare parsed structures rather than raw text when that happens.

Can it format JSON with comments or trailing commas?

No. Comments and trailing commas belong to JSON5 and JSONC, which are separate formats. Strict JSON parsers reject both, so they must be removed first.

Is two-space indentation a standard?

It is a convention, not a rule. Two spaces keeps deeply nested payloads narrow enough to read; four spaces is common in language ecosystems that already use it. The parsed result is identical either way.

Does the payload leave my browser?

No. Parsing and re-serialising both happen locally in the page, so nothing is uploaded to a server.

Go deeper

Specifications and guides