Developer Tools

JSON Formatter

Paste messy or minified JSON and get it back clean and indented, or minified to a single line. Invalid JSON is caught and the parser's error message is shown so you can find the problem. Everything runs in your browser, so the data you paste never leaves your device.

Runs in your browser. Your files and text never leave your device - nothing is uploaded.

Format, Minify, and Validate JSON

This free JSON formatter turns a dense, single-line payload into readable, indented JSON, or squeezes indented JSON back down to one line. Every time you click Format / Beautify or Minify, the input is parsed first, so the same click also works as a JSON validator: valid JSON comes out formatted, and invalid JSON produces the parser’s error message instead.

Everything runs in your browser using its built-in JSON parser. Nothing you paste is uploaded, which matters when the payload contains API keys, customer records, or internal responses. It is one of several free developer tools on this site that work the same way.

How to Use the JSON Formatter

  1. 1

    Paste your JSON

    Paste or type raw JSON into the "Raw JSON" box. It can be minified, messy, or already indented.

  2. 2

    Pick an indent size

    Choose 2, 4 or 8 spaces from the Indent dropdown. The setting applies to Format / Beautify.

  3. 3

    Format or minify

    Click "Format / Beautify" to pretty-print the JSON, or "Minify" to collapse it onto a single line. If the JSON is invalid, an error message from the parser appears instead.

  4. 4

    Copy the result

    Click Copy under the output panel to put the result on your clipboard, or Clear to start again.

No account is needed, and there is no daily limit.

Beautify vs. Minify: What Changes

Take the sample object the tool starts with. Minified, it is 56 characters on a single line:

{"name":"Alice","age":30,"hobbies":["coding","reading"]}

Formatted with a 2-space indent, it becomes 82 characters over nine lines:

{
  "name": "Alice",
  "age": 30,
  "hobbies": [
    "coding",
    "reading"
  ]
}

With a 4-space indent the same object is 98 characters, and with 8 spaces it is 130. The data is identical in every version; only whitespace changes. Beautified JSON is for reading, reviewing and diffing. Minified JSON is for sending over a network, embedding in an environment variable, or storing where size matters. For HTML, CSS or JavaScript rather than JSON, use the code beautifier.

Common JSON Syntax Errors and How to Fix Them

JSON is stricter than the JavaScript object syntax it resembles. These are the mistakes that most often make a payload fail to parse:

  • Trailing comma — {"a": 1,} is invalid. Delete the comma after the last item in an object or array.
  • Single quotes — {'a': 1} is invalid. Keys and strings must use double quotes.
  • Unquoted keys — {a: 1} is invalid. Every key must be a double-quoted string.
  • Comments — // and /* */ are not part of JSON. Remove them before parsing.
  • Missing bracket or brace — an unclosed [ or { is reported at the very end of the input, because the parser runs out of text while still expecting a comma or closing bracket.

In Chrome and Edge the error message includes the character position plus a line and column, such as “at position 7 (line 1 column 8)”, which points you straight at the problem. Other browsers word the message differently. The tool does not rewrite your input, so fix the character it points to and click Format again. If a value looks like gibberish, it may be Base64; the Base64 decoder reveals what is inside, and the JWT decoder splits a token into its JSON header and payload.

What a Parse-and-Format Round Trip Normalizes

The formatter reads your text into data and writes that data back out, so a few details can differ from the original even though the JSON is equivalent:

  • Duplicate keys — only the last value is kept, so {"a":1,"a":2} becomes {"a":2}.
  • Very large integers — numbers above 9,007,199,254,740,991 lose precision; 12345678901234567890 comes back as 12345678901234567000. Store long IDs as strings.
  • Number formatting — 1.50 becomes 1.5 and 1e3 becomes 1000.
  • Unicode escapes — "\u00e9" is written out as "é".

If you need to confirm exactly what changed between two versions of a file, paste both into the text compare tool after formatting them with the same indent.

Converting JSON to Other Formats

Once your JSON is valid, you can take it further. Turn an array of objects into a spreadsheet with the JSON to CSV converter, produce markup for an older integration with JSON to XML, or switch a config file between formats with the YAML to JSON converter, which works in both directions. Working with XML instead? The XML formatter pretty-prints and validates it the same way this tool handles JSON.

Common uses

  • Reading an API response that arrived as one long line
  • Checking a webhook payload or request body for syntax errors before sending it
  • Tidying package.json, tsconfig.json or app settings before a commit
  • Minifying JSON to fit in an environment variable or a single log line
  • Matching a project’s indentation style of 2, 4 or 8 spaces

JSON formatter terms explained

TermWhat it means here
Beautify / pretty-printRe-writing JSON with line breaks and indentation so each key and array item sits on its own line
MinifyRemoving every optional space and line break so the JSON takes up as few characters as possible
ValidateChecking that text is well-formed JSON; here it happens every time you click Format or Minify
ObjectA set of "key": value pairs wrapped in curly braces { }
ArrayAn ordered list of values wrapped in square brackets [ ]
Parse errorThe message the browser’s JSON parser returns when the text breaks JSON syntax

Frequently Asked Questions

Reviewed by Raja Jahangir · Last reviewed: October 7, 2026

How do you format and validate JSON?

To format JSON, paste it and the structure is re-indented with consistent nesting so it can be read. Invalid JSON is rejected with the JSON parser error message - the usual causes are a trailing comma, a single quote, or an unquoted key. Formatting runs in your browser.

Sources and standards

Guides for JSON Formatter