Skip to content
ToolSprint

JSON Formatter

Pretty-print or minify JSON with custom indentation.

Loading tool…

Everything is processed by JavaScript running in your browser tab. Your input is not sent to a server, logged or stored, so it is safe to use with configuration files and internal data. As always, avoid pasting production secrets into any website you do not control.

What is the JSON Formatter?

The JSON Formatter pretty-prints JSON with consistent indentation so nested objects and arrays become readable. It can also sort keys alphabetically or minify JSON into a single compact line.

Invalid input is reported with the exact line and column of the problem, plus a hint for common mistakes like trailing commas or single quotes.

Who is the JSON Formatter for?

  • Developers reading minified API responses or log entries.
  • QA testers and analysts inspecting JSON payloads.
  • Anyone who needs to minify JSON before embedding it.

Key features

  • Beautify with 2 spaces, 4 spaces or tabs, or minify to one line.
  • Optional alphabetical key sorting.
  • Live validation message, copy button and .json download.

Why use it?

API responses and log entries are usually minified, which makes them nearly impossible to read. Formatting reveals the structure instantly. Sorting keys makes two JSON documents easier to compare, and minifying reduces payload size for storage or transport.

How to use the JSON Formatter

  1. Paste JSON into the input box, or click “Load sample”.
  2. Check the validation message under the box.
  3. Choose 2 spaces, 4 spaces or tabs, and optionally enable key sorting.
  4. Click “Format / beautify” or “Minify”.
  5. Copy the output or download it as a .json file.

Examples

Reading an API response

A one-line response such as {"user":{"id":7,"roles":["admin","editor"]}} becomes an indented tree where you can immediately see that roles is an array inside user.

Preparing a config file

Format with 2 spaces and sorted keys before committing a configuration file, so future diffs only show real changes.

Supported formats and inputs

  • Input: standard JSON (RFC 8259) up to about 10 MB.
  • Output: formatted or minified JSON, downloadable as .json.

Limitations to know about

  • JSON5, JSONC (with comments) and JavaScript object literals are not valid JSON and will be reported as errors.
  • Numbers larger than 2^53 lose precision in JavaScript and may be changed when reformatted.
  • Duplicate keys are collapsed to the last value, as JSON.parse does.

Privacy

Everything is processed by JavaScript running in your browser tab. Your input is not sent to a server, logged or stored, so it is safe to use with configuration files and internal data. As always, avoid pasting production secrets into any website you do not control.

Frequently asked questions

Why does it say my JSON is invalid?

The most frequent causes are trailing commas, single-quoted strings, unquoted keys and comments. The error shows the line and column, and a hint names the likely issue.

Does sorting keys change my data?

Only the order of object keys changes. Array order is never changed, and values are untouched.

What is the difference between this and the JSON Validator?

Both use the same parser. The validator focuses on checking and explaining errors as you type; the formatter focuses on producing clean output.

JSON Validator

Check JSON syntax and pinpoint errors by line and column.

Base64 Encoder/Decoder

Encode and decode Base64 text and files, UTF-8 safe.

HTML Formatter

Indent and tidy HTML markup, or minify it.

URL Encoder/Decoder

Percent-encode or decode URLs and query parameters.

Browse all developer tools →