256 Tools

JSON Formatter — Beautify, Minify & Validate JSON Online (Free, Private)

Indent:

Load sample

Your JSON is processed entirely in your browser — it is never sent to a server.

Related external tools

Some links are affiliate links.

Related tools

This free online JSON formatter lets you paste any JSON and instantly beautify it (pretty print with indentation), minify it (one compact line), or validate it. If your JSON has an error, the tool shows you exactly which line and column is wrong, highlights that spot in the editor, and shows a code-style excerpt with a ^ caret pointing at the problem — so you can fix it in seconds. Choose 2-space, 4-space or tab indentation, sort all object keys alphabetically, switch to a collapsible tree view for deep or complex JSON, then copy the result or download it as a .json file. All processing happens locally in your browser — your data is never uploaded, so API keys, tokens or any private JSON are safe to paste.

How to use

  1. Paste your JSON into the input box above, or click 'Load sample' to try an example, or click 'Open file' to load a .json file from your device.
  2. Choose Beautify to add indentation and line breaks, or Minify to collapse everything into one line.
  3. If there is a syntax error, the line and column number appear highlighted, with a caret (^) pointing at the exact position.
  4. Adjust the indent size (2 spaces, 4 spaces or tab), toggle 'Sort keys' to normalise key order, or switch to Tree view to explore the structure.
  5. Click Copy to copy the result, or Download to save it as a .json file. No account needed — everything runs in your browser.

Beautify and Minify

Beautify (pretty print)

Beautifying JSON adds line breaks and consistent indentation so the structure is immediately readable, no matter how deeply nested. This is the most common use: pasting a one-line API response and instantly seeing the shape of the data.

Minify (compress)

Minifying JSON removes all non-essential whitespace and line breaks to produce a single, compact line. This reduces file size and is useful when embedding JSON in source code, environment variables, URLs or API requests where size matters.

Indent size (2 / 4 spaces / tab)

Choose the indentation style that matches your team or project conventions. 2 spaces is the most common default. 4 spaces improves readability on wide screens. Tab is useful when your codebase already uses tab indentation. The indent setting only applies when beautifying; it is ignored during minify.

Features

Error location (line & column) with highlight

When JSON is invalid, the tool reports the exact line and column where the parser gave up, highlights that line in the input editor, and shows a compiler-style excerpt with a caret (^) pointing at the problem character. It also detects common causes — trailing commas, single-quoted strings, JavaScript comments, unquoted keys, NaN/Infinity — and shows a plain-text hint so you can fix it without guessing. This is the key feature that sets this formatter apart from simple online tools that just say 'Invalid JSON'.

Sort keys

When 'Sort keys' is enabled, every object in the JSON (at every nesting level) has its keys sorted in ascending alphabetical order (code-point order, not locale-dependent). This is useful for normalising JSON before comparing two versions with a diff tool — when keys are in the same order, differences are easier to spot. Array element order is never changed.

Tree view with collapse / expand

Switching to Tree view renders the parsed JSON as a hierarchical tree. Each object and array can be independently collapsed or expanded with a click (or Enter / Space for keyboard navigation). This is especially useful for large or deeply nested JSON where you want to explore the structure without scrolling through hundreds of lines of text.

Copy and download

Click the Copy button to send the formatted result straight to your clipboard — a 'Copied!' confirmation appears immediately. Click Download to save the result as a .json file, generated entirely in your browser using a Blob URL (no server involved). Both actions fire only on the formatted output, never on your raw input.

Character and byte counts

The stats bar below the result shows input and output character counts (JavaScript string length) and UTF-8 byte sizes. When you minify, it also shows how many bytes were saved and the percentage reduction. Numbers are formatted with locale-appropriate digit grouping (e.g. 1,234 in English). Note that the JSON text itself is never locale-formatted — it is always valid, copy-pasteable JSON.

Safe to use with private data

All parsing, formatting and validation happens entirely in your browser using the standard JSON.parse and JSON.stringify APIs. Nothing is sent to any server, logged, or stored. You can safely paste JSON that contains API keys, access tokens, passwords, or any other sensitive data.

Use cases

Beautify an API response

Copy a JSON response from a browser devtools Network tab, curl, or Postman and paste it here. The formatted output makes it easy to understand the shape of the data, spot missing fields, and verify types — much faster than staring at a one-line blob.

Find the error in a broken JSON

When a config file, POST body, or JSON fixture fails to parse, paste it here. The error panel shows the exact line and column, highlights the problem in the editor, and gives a hint about common causes such as trailing commas, JavaScript-style comments, or unquoted keys. Saves the back-and-forth of reading a cryptic parser message.

Minify JSON for embedding

Turn a nicely formatted JSON config into a single line for pasting into a shell script, environment variable, Docker label, or URL parameter. The stats bar shows exactly how much you saved.

Normalise keys before comparing

Before running a JSON diff, sort both documents' keys with the 'Sort keys' option so that any differences are due to value changes rather than key-order differences. This is useful when comparing API responses over time or across environments.

Common JSON errors and notes

  • Trailing commas are not allowed: [1, 2,] and {"a":1,} are invalid JSON (they are valid in JSON5/JSONC, which is a different format).
  • Strings and keys must use double quotes: 'hello' and {a:1} are not valid JSON — use "hello" and {"a":1}.
  • Comments are not supported: // and /* */ are JavaScript syntax, not JSON. If you need comments, use JSONC or JSON5 (which this tool does not parse).
  • NaN, Infinity and undefined are not JSON values: they are JavaScript values that cannot appear in valid JSON.
  • Very large integers may lose precision: numbers above 2^53 (9007199254740992) are parsed as IEEE 754 doubles, so digits may change. This is a limitation of JSON.parse and JavaScript's number type.
  • Duplicate keys are allowed but produce unpredictable results: {"a":1,"a":2} is technically valid JSON but results in {"a":2} because JSON.parse uses last-wins semantics for duplicate keys.

Frequently asked questions

Can I see exactly which line and column has the JSON error?
Yes. When JSON fails to parse, the tool displays the exact line and column number, highlights that line in the editor, shows a code-style excerpt with a ^ caret pointing at the problem, and gives a hint about the most likely cause (trailing comma, single quotes, comments, etc.).
Can I both beautify (pretty print) and minify JSON?
Yes. Use the Beautify / Minify toggle at the top. Beautify adds indentation and line breaks; you can choose 2 spaces, 4 spaces or a tab. Minify removes all unnecessary whitespace and produces a single line. The stats bar shows the byte size reduction when minifying.
Is my JSON sent to a server?
No. All parsing, formatting and validation runs entirely in your browser using the built-in JSON.parse and JSON.stringify functions. Your JSON is never uploaded, stored or logged anywhere. It is safe to paste sensitive data such as API keys or tokens.
Can I sort object keys alphabetically?
Yes. Enable the 'Sort keys' checkbox and every object in the JSON (at every level of nesting) will have its keys sorted in ascending alphabetical order. Array element order is never changed. This is useful for normalising JSON before comparing two versions.
Does it support JSON with comments or trailing commas (JSON5 / JSONC)?
No. This tool follows the standard JSON specification (RFC 8259), which does not allow comments or trailing commas. If your input contains them, the tool shows a syntax error with a hint explaining what is wrong. For JSONC, you would need to strip comments first.
Can I handle large JSON files?
Yes, up to a few megabytes. Very large files may be slow to process or render in Tree view, so the tool automatically disables Tree view for oversized input and warns you. For enormous files (tens of MB), a dedicated desktop tool may be more suitable.
Can I copy or download the formatted result?
Yes. Click Copy to send the formatted JSON to your clipboard, or click Download to save it as a .json file. Both are generated entirely in your browser without any server round-trip.

We use cookies for ads and analytics.