JSON formatter and beautifier

Paste your JSON and this JSON formatter will validate it and pretty-print it with 2 spaces, 4 spaces or a tab. You can also minify it or sort the keys. If the JSON is invalid, the error shows the line and column.

  • Free
  • No sign-up
  • Runs in your browser

Runs in your browser — your text is never sent to our servers.

How to use JSON Formatter

  1. Paste your JSON into the input box.
  2. Click Format and choose 2 spaces, 4 spaces or tab for the indentation, or click Minify to remove all whitespace.
  3. Tick the sort-keys option if you want object keys in alphabetical order.
  4. If there is an error, read its line and column, fix the JSON and format it again, then copy the result.

Features

  • Pretty-print JSON with 2 spaces, 4 spaces or a tab
  • Minify JSON into a single compact line
  • Optional alphabetical sorting of object keys
  • Validation with a clear error message and the line and column of the problem
  • Strict parsing according to the JSON standard, RFC 8259
  • Handles files up to 10 MB
  • Copy the formatted output in one click
  • Processing in the browser, with no daily limit

Supported formats and limits

  • Maximum input: 10,000,000 characters

Examples

InputResult
{"name":"Ana","age":30}Format, 2 spaces: a block with "name": "Ana" on one line and "age": 30 on the next, each indented by 2 spaces
{ "a": 1, "b": [1, 2] }Minify: {"a":1,"b":[1,2]}
{"b":1,"a":2} with sort keys on{"a":2,"b":1}
{"a":1,}Error: the trailing comma is not valid JSON, and the message gives its line and column

Limitations

  • The formatter follows the JSON standard (RFC 8259) strictly. It does not accept JavaScript-only extensions such as comments, trailing commas, single quotes or unquoted keys.
  • Input larger than 10 MB is not processed.
  • Sorting keys changes the order of object keys. Array order is never changed.
  • Very large numbers may lose precision, because the browser parses them as standard floating-point values.

Learn more

JSON (JavaScript Object Notation) is a text format for structured data, defined in RFC 8259. It has only six value types: objects, arrays, strings, numbers, true or false, and null. Despite looking like JavaScript, it is stricter: keys and strings need double quotes, and comments and trailing commas are not allowed. Those strict rules explain most of the errors people see.

Formatting, also called beautifying or pretty-printing, adds line breaks and indentation so you can read nested data. It changes only whitespace, never the data. Minifying does the opposite by removing whitespace to reduce size, which is handy for network payloads and embedded configuration.

Choose indentation to match your project: 2 spaces is common in JavaScript and web projects, 4 spaces in many Python and Java codebases, and a tab if your editor is set up for it. Sorting keys produces a stable order, making version-control diffs smaller and two documents easier to compare. When validation fails, use the reported line and column to jump straight to the first problem; later errors are often a side effect of it.

Frequently asked questions

How do I format JSON online?

Paste the JSON and click Format. Choose 2 spaces, 4 spaces or a tab and the tool returns readable, indented JSON.

How can I check if my JSON is valid?

Paste it and run Format. If it is valid you get the formatted output, and if not you see the error with its line and column.

How do I minify JSON?

Click Minify. All spaces and line breaks outside strings are removed, which makes the JSON smaller for storage or transfer.

Why does my JSON with comments or single quotes fail?

Standard JSON does not allow comments, single-quoted strings or trailing commas. Remove them or quote the keys with double quotes.

Can I sort the keys alphabetically?

Yes, tick the sort-keys option before formatting. It is useful for comparing two JSON files.

Is my JSON sent to a server?

No. Formatting and validation run in your browser, so API responses and config files stay on your device.

Should I use the JSON Formatter or the JSON Validator?

Use the JSON Formatter when you want readable, indented JSON; it also reports syntax errors. The JSON Validator is for a quick yes or no check with the exact line and column of the first error, and the JSON Minifier strips whitespace for production.

Sources

Last reviewed: September 29, 2026