Skip to content
1123.net
EN
1123.net

Search tools

Filter the tool directory. Everything runs in your browser.

Type to filter tools. Press Enter to open the first result.

JSON Formatter

This JSON formatter pretty-prints, minifies and validates JSON without sending it anywhere. Invalid input is reported with the line and column where parsing failed, and an optional key sort makes diffs easier to read.

Your data is processed locally in your browser and is not uploaded to our server.

How to use this tool

  1. 1 Paste or type JSON into the left box; the input is validated immediately.
  2. 2 Press “Format” to pretty-print it, or “Minify” to remove all optional whitespace.
  3. 3 Choose two spaces, four spaces or a tab, and enable “Sort keys” for a stable key order.
  4. 4 Copy or download the result, or clear both boxes to start again.

Formula and calculation logic

Formatting

JSON.stringify(value, null, indentation)

Formatting parses the JSON into a value and re-serialises it with the chosen indentation. Minifying uses the same serialisation without indentation or extra whitespace.

Error positions

Invalid JSON → position, then line and column

When parsing fails, the parser position is converted into a line and column number. The browser or runtime message is shown after a short localized prefix.

Worked example

Formatting a compact object

A one-line API response needs to be readable.

  1. Input: {"b":2,"a":1}
  2. Format with two spaces
  3. Output: { "b": 2, "a": 1 }

The formatted version is easier to inspect. Minifying returns the original compact form without spaces.

Finding a syntax error

A trailing comma breaks a configuration file.

  1. Paste the file and read the error line
  2. The error points at the line with the bad token
  3. Remove the token and format again

The line and column numbers point to the first place where the parser could not continue.

Edge cases and accuracy

JSON is not JavaScript

Comments, trailing commas, single quotes and undefined are not valid JSON. Use a strict JSON linter if the file is JSON5 or JSONC.

Large documents

Formatting happens locally, but very large documents can take a moment. Browser memory limits apply; split huge files into smaller parts.

Key order

JSON objects are unordered by specification. Enabling key sorting produces a deterministic output, which is useful for comparing files.

Frequently asked questions

Does the formatter fix invalid JSON? +

No. It reports the problem instead of guessing. Fix the reported line or column and format again.

What is the difference between formatting and minifying? +

Formatting adds indentation and line breaks for readability; minifying removes optional whitespace to make the payload smaller. Both preserve the same data.

Can I sort keys? +

Yes. Enable “Sort keys” and the formatter sorts object keys alphabetically at every nesting level. Array order is never changed.

Is my JSON uploaded? +

No. Parsing and formatting run in your browser; the data is not sent to a server or stored.

Why does my valid JavaScript object fail? +

JavaScript object syntax allows comments, trailing commas and single quotes, which JSON does not. Remove those features or use a JSON5 tool.