JSON Formatter

Paste messy or minified JSON and get it back neatly indented, or squeeze it onto one line. The JSON formatter keeps big numbers and strings exactly as written.

Updated
Runs in your browser. Your data is not uploaded.
Mode
Formats as you type for inputs up to 200 KB.

How to use the JSON Formatter

  1. Paste JSON into the input box, upload a .json file up to 5 MB, or press Load sample.
  2. Choose Beautify or Minify, the indent (2 spaces, 4 spaces, or tab), and whether to Sort keys A-Z.
  3. Press Format. The result appears with line numbers and the size before and after. Press Copy or Download .json.

How it works

The formatter reads your JSON with a lossless parser and writes it out again with the spacing you chose.

  • Beautify puts each value on its own line and indents nested objects and arrays.
  • Minify removes every space and line break that isn't inside a string.
  • Numbers are kept exactly as written. Integers larger than 2^53 and decimals such as 1.0 don't lose digits, which a standard JavaScript parser would do.
  • Strings are kept byte for byte, including Unicode escapes such as \u00e9.

Examples

{"name":"Utilza","tools":["json","csv"],"free":true} formatted with 2 spaces:

{
  "name": "Utilza",
  "tools": [
    "json",
    "csv"
  ],
  "free": true
}

Minifying that output gives back the one-line original, 52 characters long.

When to beautify and when to minify

APIs and build tools often send JSON on a single line to save space, which makes it hard to read. Beautify it when you need to inspect a response, review a config file, or compare two versions: with one value per line, a diff shows exactly what changed.

Minify goes the other way. Removing whitespace makes the payload smaller, which helps for request bodies, config files bundled with an app, and anywhere storage or bandwidth is tight.

Sorting keys A-Z is useful before comparing two JSON documents, because the same data in a different key order then lines up.

Limitations

  • Input is limited to 5 MB.
  • Invalid JSON is not formatted. You get the line and column of the first error and a link to the JSON validator.
  • Duplicate keys give a warning, and the last value wins.
  • Comments and trailing commas are not valid JSON and are rejected.

Frequently asked questions

Is my JSON sent to a server?

No. Formatting runs in your browser, and nothing is uploaded or stored.

What is the difference between beautify and minify?

Beautify adds line breaks and indentation for reading. Minify removes all unnecessary whitespace to make the file smaller.

Will formatting change my numbers?

No. The formatter keeps large integers and decimals exactly as written.

What if my JSON has an error?

The formatter shows the line and column of the first error. The JSON Validator explains how to fix it.

Often used together with the JSON Formatter.

  • JSON Validator

    Checks JSON syntax and explains any error in plain English.

  • JSON to YAMLConverters

    Turns JSON into readable YAML for configuration files.

  • JSON to CSVConverters

    Turns an array of JSON objects into a CSV table.