JSON tool

JSON Formatter

Format, validate, and minify JSON in your browser. Choose two spaces, four spaces, or tabs for indentation.

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

Result

Your result will appear here.

How to use JSON Formatter

  1. Paste JSON into the input.
  2. Choose an indentation style and select Format or Minify.
  3. Copy the formatted result or clear the editor.

Example

{"user":{"id":1,"name":"Alice"}}

Common use cases

  • Reading a minified API response from a browser network tab or a log line by indenting it so nested objects and arrays become visible.
  • Cleaning up a hand-edited configuration file before a code review, so the diff shows real value changes instead of whitespace noise.
  • Checking the shape of a request payload attached to a bug report, then copying the indented text back into the ticket.

Input and output examples

InputOutputNotes
{"user":{"id":1,"name":"Alice"}}{ "user": { "id": 1, "name": "Alice" } }Two-space indentation, the default.
[1,{"ok":true}][ 1, { "ok": true } ]Tab indentation.

Common mistakes to avoid

  • JSON is stricter than JavaScript. Trailing commas such as {"a": 1,} and comments such as // are not valid under RFC 8259, even though JavaScript object literals accept them.
  • Formatting re-serializes the document. The output carries the same data but is not byte-for-byte identical to the input, so do not compare the two as text.
  • Duplicate keys are not an error for the parser. With {"a":1,"a":2} the result keeps only "a": 2, so a formatted file can silently drop a value. Search the source when two keys look alike.

Technical details

Uses the browser’s native JSON.parse and JSON.stringify, which implement the grammar in ECMA-404 (The JSON Data Interchange Syntax) and RFC 8259. Input is parsed and written again, so whitespace is rebuilt and numbers are written in JavaScript’s normal form. Processing happens locally and the tool code does not send the input to a server.

Frequently asked questions

Is my JSON uploaded?

No. Formatting and validation run locally in your browser, and the tool code does not send the input to a server.

Which indentation styles are supported?

Two spaces, four spaces, and tabs.

Why does the output look different from my original file?

The formatter parses the document and writes it again. Key order and values are kept, but line breaks and indentation are rebuilt, and a number such as 1.0 is written as 1.

Why did a large ID change after formatting?

JavaScript numbers are 64-bit floating-point values, and only integers up to 9007199254740991 (Number.MAX_SAFE_INTEGER) are exact. Larger values are rounded. Keep such IDs as strings in the source JSON.

Can the formatter fix invalid JSON?

No. It does not repair syntax and reports an error instead. Use the JSON Validator to find the line and column of the problem, then fix it by hand.

What happens if two keys have the same name?

JSON.parse keeps the last value without an error, so the earlier value is lost from the formatted output.