Developer Tools

JSON Formatter & Beautifier

Turn messy or minified JSON into clean, readable, indented code, or compress it into a single line. Errors are reported with the exact line and column, and your data never leaves your browser.

Format JSON

Paste JSON from an API response, log file or config, then choose Format or Minify.

How to Format JSON

  1. Paste your JSON into the top box. It can be minified, partly indented or already formatted.
  2. Choose the indentation you prefer and whether to sort keys alphabetically.
  3. Press Format to beautify it, or Minify to remove all unnecessary whitespace.
  4. Copy the result or download it as a .json file.

If the JSON contains a syntax error, the formatter shows the error message together with the line and column where parsing failed and a snippet of the text around it.

Before and After

Minified JSON from an API is efficient to send but hard to read:

{"id":42,"user":{"name":"Ayesha","roles":["admin","editor"]},"active":true}

After formatting with 2 spaces, the structure is clear:

{
  "id": 42,
  "user": {
    "name": "Ayesha",
    "roles": [
      "admin",
      "editor"
    ]
  },
  "active": true
}

When to Format and When to Minify

  • Format when reading API responses, debugging, reviewing configuration files such as package.json or tsconfig.json, writing documentation or comparing two versions of a file.
  • Minify before embedding JSON in code, storing it in a database field, sending it in a request body or URL, or reducing the size of static data files.
  • Sort keys to make two JSON documents easier to compare with a diff tool, or to keep configuration files consistent in version control. Arrays are never reordered, because the order of array items is meaningful.

JSON Syntax Rules

  • Keys and string values must use double quotes. Single quotes are not allowed.
  • No trailing comma after the last item in an object or array.
  • Allowed values are strings, numbers, true, false, null, objects and arrays. undefined, functions, dates and NaN are not valid JSON.
  • Comments (// or /* */) are not part of standard JSON.
  • Special characters inside strings, such as quotes, backslashes and line breaks, must be escaped with a backslash.

Large Numbers

JavaScript, and therefore every browser-based formatter, stores numbers as 64-bit floating point. Integers larger than 9,007,199,254,740,991 (253 − 1), such as some database IDs and Twitter/X IDs, may lose precision when parsed. If your data contains very large IDs, keep them as strings in the JSON.

Privacy

Formatting uses your browser's built-in JSON parser. Nothing is uploaded, which makes this tool safe for API responses that contain tokens, customer data or internal configuration.

Frequently Asked Questions

How do I pretty-print JSON?

Paste the JSON into the formatter, choose 2 spaces, 4 spaces or tabs and press Format. The indented result can be copied or downloaded.

What is the difference between formatting and minifying JSON?

Formatting adds line breaks and indentation so people can read it. Minifying removes all unnecessary whitespace to make the data as small as possible for sending or storage. Both contain exactly the same data.

Why does the formatter say my JSON is invalid?

The most common causes are single quotes, a trailing comma after the last item, unquoted keys, comments, or a missing bracket. The error message shows the line and column. The JSON Validator can fix several of these automatically.

Does sorting keys change my data?

No. Objects in JSON are unordered, so sorting keys keeps the same data. Arrays are never reordered.

Is there a size limit?

There is no fixed limit. Files of several megabytes format in a moment on most computers. Very large files depend on your device's memory.

Is my JSON sent to a server?

No. Formatting happens entirely in your browser, so sensitive data stays on your device.