Prefer to watch? This short walkthrough covers the same steps as the guide below.

A JSON formatter takes raw, minified or hand-edited JSON and rewrites it into a clean, indented structure you can actually read. This guide covers what JSON is, how to use the JSON Formatter on JsonCherry step by step, the errors it catches and how to fix them, and the standards it follows. Everything the tool does runs in your browser — nothing you paste is uploaded or stored.

What is JSON, and why format it?

JSON (JavaScript Object Notation) is a lightweight, text-based format for structured data. It is defined by RFC 8259 and ECMA-404, and it is the default payload format for web APIs, configuration files, log pipelines and message queues. A JSON document is either an object ({ ... }) mapping string keys to values, or an array ([ ... ]) of values; values are strings, numbers, true, false, null, objects or arrays.

JSON is compact for machines but hard for people to read once it is on a single line. Formatting — also called pretty-printing or beautifying — adds consistent indentation and line breaks so nested structure is obvious. Minifying does the reverse for production traffic.

JSON vs XML vs YAML

AspectJSONXMLYAML
Syntax weightLight, no closing tagsHeavy, closing tags and attributesVery light, indentation-based
CommentsNot allowedAllowedAllowed
Schema / validationJSON Schema (optional)XSD, DTD (mature)Rare in practice
Data typesBuilt-in: string, number, boolean, nullEverything is textBuilt-in, plus dates
Best forAPIs, config, storageDocuments, enterprise messagingHuman-edited config (CI, Kubernetes)

Need to move between formats? Use the JSON to XML and JSON to YAML converters.

Step by step: using the JSON Formatter

  1. Paste or drop your JSON into the input box. You can also click Upload file or drag a .json or .ndjson file onto it.
  2. Choose your options: indent width (2 spaces, 4 spaces or a tab), sort keys A‑Z or Z‑A, collapse deep nesting, or remove empty values.
  3. Click Format to pretty-print, or Minify to compress to one line. Ctrl+Enter also formats.
  4. Check the result: the output is syntax-highlighted, and a summary line shows object, array and key counts, nesting depth and byte size.
  5. Copy or download the output, or use Copy link to share the input through the URL.

What each control does

  • Format — re-indent and validate.
  • Minify — strip all optional whitespace.
  • Validate — check syntax only, and warn about duplicate keys.
  • Repair — best-effort fix for comments, trailing commas, single quotes and unquoted keys.
  • Escape / Unescape — convert to and from a JSON string literal.
  • JSON Lines (NDJSON) — treat the input as one JSON value per line.
  • JSON Pointer — pull a single value out of the document using RFC 6901 syntax, for example /user/address/city.
  • Example / Clear — load a sample, or reset both boxes.

Common JSON syntax errors and how to fix them

The formatter reports the exact line and column where parsing failed. These are the usual causes:

Trailing comma

{ "a": 1, "b": 2, }   →   { "a": 1, "b": 2 }

Single quotes instead of double

{ 'name': 'Ada' }   →   { "name": "Ada" }

Unquoted key

{ name: "Ada" }        →   { "name": "Ada" }

Mismatched brackets

{ "list": [1, 2, 3 }   →   { "list": [1, 2, 3] }

Comments

JSON has no comment syntax. Remove // and /* ... */, or click Repair to strip them automatically. For all of the errors above, the fastest fix is Repair, which normalises them in one pass without touching the contents of your strings.

Reading a validation error

An error such as Unexpected token at line 4, column 17 points at the first character the parser could not accept. The real mistake is usually just before that position — a missing comma at the end of the previous line, for example.

Practical use cases

Preparing JSON for production

Keep a formatted copy while you work, then Minify before shipping. Minified JSON is smaller over the wire; gzip narrows the gap, but every byte still counts on high-traffic endpoints.

Debugging an API response or log line

Paste the raw response body and hit Format, and the structure becomes scannable. Use JSON Pointer to jump straight to a nested value, or Collapse depth to hide everything below the level you care about.

Writing configuration files

Use 2-space indentation, sort keys for stable diffs, and validate the file in CI so a broken config fails the build rather than the running service.

Working with large files

Formatting happens in your browser's JavaScript engine, so multi-megabyte documents can be slow. Turn off Syntax highlight for very large output, and prefer NDJSON for big record sets so each line can be processed independently.

Standards and best practices

Specification compliance

The tool uses the browser's native JSON parser, which implements RFC 8259 / ECMA-404. That means strictly double-quoted keys and strings, no trailing commas, no comments, and numbers with no leading zeros or trailing decimal point.

Indentation

Two spaces is the most common convention and keeps lines short; four spaces improves readability for deeply nested data; tabs let each reader choose their own width. Pick one per project and enforce it.

Unicode and special characters

JSON is Unicode text, normally encoded as UTF-8. You can paste emoji, accented letters and non-Latin scripts directly and the formatter preserves them. Inside a string, the characters that must be escaped are the double quote (\"), the backslash (\\) and control characters such as newline (\n) and tab (\t). The \uXXXX form is also valid and is left as-is.

Duplicate keys

A JSON object should not repeat a key. If it does, parsers keep only the last value and silently discard the rest. The formatter flags duplicates with their line numbers so you can fix the source.

Try these examples

Paste each one into the JSON Formatter and click Format (or Validate for the last one).

1. Simple API response

{"status":"ok","code":200,"data":{"id":42,"name":"Ada Lovelace"}}

2. Nested object

{"user":{"name":"Ada","address":{"city":"London","country":"UK","geo":{"lat":51.5072,"lng":-0.1276}}}}

3. Array of objects

[{"id":1,"title":"Analytical Engine"},{"id":2,"title":"Notes G"},{"id":3,"title":"Bernoulli numbers"}]

4. Invalid JSON (for Validate)

{"name":"Ada","roles":["admin" "editor"],}

Is my data private?

Yes. The JSON Formatter is 100% client-side: your input is parsed by JavaScript in your own browser and is never uploaded, logged or stored on a server. Your formatting options and a short history of recent inputs are saved only in your browser's local storage, and you can clear them at any time.

Try it now

Open the JSON Formatter, paste one of the examples above, and press Ctrl+Enter. For strict checking use the JSON Validator; to explore structure visually, use the JSON Tree Viewer.

Share this article: Twitter LinkedIn Email

Looking for a tool to try out what you just read? Browse the full tools catalog.