Skip to main content

JSON Formatter

Format, minify and validate JSON online

No server uploadErrors located by line/columnFormat / minify / sort

Last updated: 2026-10-09

About this tool

The JSON formatter turns dense, hard-to-read JSON into a neatly indented structure, or compresses JSON onto a single line to save space. When the JSON has a syntax error, the tool points to the exact line and column so you can fix it fast. All parsing and formatting happen in your browser, so anything you paste stays on your device: no upload, no logging and no signup.

Features

Fully local processing

Parsing and formatting happen in the browser with no network request, so sensitive config is safe.

One-click beautify

Expand dense JSON into indented lines, with a choice of 2 spaces, 4 spaces or no wrapping.

One-click minify

Strip all unnecessary whitespace to a single line for configs or smaller payloads.

Sort keys

Recursively reorder object keys alphabetically to make two JSON files easy to diff.

Syntax error location

When parsing fails you get the exact line and column instead of a vague English error.

Live size stats

Node count and byte size update as you type, so you can gauge the data size at a glance.

How to use

  1. 1

    Paste your JSON

    Paste the JSON into the input box - copy it from an API response, log or config file.

  2. 2

    Choose an indent

    Pick 2 spaces, 4 spaces or no wrap; "No wrap" gives you the minified single line.

  3. 3

    Click an action

    Use "Format" to beautify, "Minify" to strip whitespace, or "Sort keys" to reorder object keys.

  4. 4

    Copy the result

    Once it looks right, click "Copy" and paste it back into your code or config.

Options

Indent
Controls the indentation width. 2 spaces is a common front-end convention, 4 spaces reads better, and "No wrap" is equivalent to minified output.
Error position
Shows the line and column (1-based) of a syntax error. Some errors cannot be located by the engine, in which case only the reason is shown.

Common use cases

  • Expand a dense API response to read and debug it
  • Minify JSON to shrink a config file or payload
  • Validate hand-written JSON and locate the error
  • Sort keys alphabetically to diff two JSON files
  • Tidy up a JSON snippet pasted from a log
  • Check whether a request or response body has the expected shape

FAQ

Questions you may have about this tool

Is my data uploaded to a server?

No. Parsing and formatting run entirely in the browser with no upload request - check the Network panel in dev tools to confirm.

How large a JSON file is supported?

There is no hard limit, but very large payloads (tens of MB) may stutter due to browser memory - split them up first.

Why did my Chinese characters turn into gibberish?

The tool handles text as standard UTF-8 and does not escape Chinese. If it was already garbled when pasted, the source encoding is likely the cause.

Does formatting change the data itself?

No. Formatting only changes whitespace; field names and values stay identical, which you can verify by re-parsing.

Does it support JSON5 or JSON with comments?

Not currently. The tool follows the standard JSON spec, so comments, single quotes and trailing commas are treated as errors.

Does sorting keys reorder arrays?

No. Sorting only applies to object keys; the order of array elements is preserved.

Why is no line/column shown for an error?

Some syntax errors give the browser engine no position information. The tool then shows just the reason - check brackets and quotes near the description.

What if the copy button does nothing?

Copying relies on the browser clipboard API, which is restricted in some contexts. You can select the result and copy it manually instead.