JSON Formatter & Validator

Paste JSON to pretty-print, minify or validate it. Errors are pinpointed to the exact line and column with a plain-English explanation — all in your browser.

Runs in your browser
Indent
Open file
Paste JSON or load the sample
Formatted JSON appears here.

Your data never leaves your computer. All processing happens 100% locally in your browser.

How to use the JSON Formatter

  1. Paste your JSON into the Input JSON box, drop a .json file on it, or click Load sample.
  2. The output updates as you type. Choose Beautify with 2 spaces, 4 spaces or tabs — or Minify to strip all whitespace.
  3. If the JSON is invalid, the error is shown with its line and column. Click Jump to error to select the exact character in the input.
  4. Switch to Tree to explore nested data; click any value to copy its path (e.g. $.variants[0].color).
  5. Click Copy or Download to save the result.

What is a JSON formatter?

A JSON formatter (also called a JSON beautifier or pretty-printer) takes compact or messy JSON and rewrites it with consistent indentation and line breaks so humans can read it. APIs usually return minified JSON on a single line to save bytes; formatting it is the first step when you debug a response, review a config file or write documentation. This tool also works the other way: Minify removes every unnecessary space and newline for the smallest possible payload.

Formatting and validation go hand in hand. The formatter parses your input with the same strict rules as JSON.parse(), so anything it accepts will be accepted by any standards-compliant parser (RFC 8259).

Common JSON errors and how to fix them

When parsing fails, the validator reports the exact line and column, highlights the character and explains the problem. These are the mistakes it catches most often:

ErrorInvalidValid
Trailing comma[1, 2, 3,][1, 2, 3]
Single quotes{'id': 1}{"id": 1}
Unquoted key{id: 1}{"id": 1}
Comments{"a": 1 // note}Remove the comment
Missing comma{"a": 1 "b": 2}{"a": 1, "b": 2}
Special numbersNaN, Infinity, 01null, 1
Raw line break in string"line 1⏎line 2""line 1\nline 2"

Many of these are legal in JavaScript object literals, JSON5 or YAML but not in JSON — a common source of confusion when copying data out of source code.

Warnings beyond syntax

Some JSON is technically valid but still risky. The validator warns about duplicate keys (most parsers silently keep only the last value) and about integers larger than 253 (9,007,199,254,740,991), which JavaScript cannot represent exactly — a frequent problem with 64-bit database IDs. If you see that warning, send such IDs as strings.

Beautify vs. minify: which should you use?

Use beautified JSON for anything people read: config files in Git (so diffs are line-based), documentation and debugging. Two-space indentation is the most common convention in JavaScript projects; four spaces is typical in Python's json.dumps(indent=4). Use minified JSON for network payloads and storage. Note that gzip or Brotli compression on your server already removes most of the size difference, so readability usually wins for files you commit.

Tree view and key sorting

For large documents, the Tree view lets you collapse objects and arrays and see item counts at a glance. Sort keys orders every object's keys alphabetically at all levels — handy for comparing two JSON documents in the Diff Checker, since key order otherwise produces noisy diffs. Need a different format? Convert to YAML, CSV or TypeScript types.

Tools that pair well with the JSON Formatter

  • JavaScript Formatter — Unminify and pretty-print JavaScript, JSON or JSX with your preferred indentation and brace style — or strip whitespace and comments with a verified minifier.
  • Base64 Encode / Decode — Convert text to Base64 and back with full UTF-8 support (accents, emoji), switch to URL-safe Base64, or drop a file to get its Base64 string or data URI.
  • CSV to JSON — Paste CSV or TSV and get a JSON array of objects.
  • JSON to Markdown Table — Turn API responses or LLM-generated JSON arrays into a clean, aligned Markdown table for READMEs, docs and pull requests.

Frequently asked questions

Is my JSON uploaded to a server?
No. Parsing, formatting and validation run entirely in your browser with JavaScript. Nothing is sent or stored, so it is safe for API responses and config files that contain internal data.
Why does the validator reject comments and trailing commas?
The JSON standard (RFC 8259) does not allow them. Formats such as JSON5, JSONC (used by VS Code settings and tsconfig.json) and YAML do — but a strict parser like JSON.parse() will throw an error.
How large a file can I format?
Files of several megabytes format in well under a second on a modern device. Syntax highlighting is turned off automatically for very large outputs to keep the page responsive.
Does formatting change my data?
Only whitespace changes — unless you enable Sort keys, which reorders object keys. Two caveats come from JavaScript itself: duplicate keys collapse to the last value, and integers above 253 lose precision. The tool warns you when either happens.
What is the difference between JSON and a JavaScript object?
JSON is a text format with stricter rules: keys must be double-quoted strings, strings use double quotes only, and functions, undefined, comments and trailing commas are not allowed.

Related tools