🍱 Lunchbox Hands

JSON Prettify / Minify

Format, validate, and minify JSON

Paste your JSON into the editor and click Format to prettify it with proper indentation, or Minify to compress it into a single line. Invalid JSON is flagged immediately with a clear error message. Everything runs locally in your browser — your data never leaves your machine.

Not sure what an error like Unexpected token is pointing at? Our guide to JSON "Unexpected token" errors decodes each browser's message, from trailing commas to invisible byte order marks.

How the formatter works

There is no custom parser here. The text you paste goes through the browser's own JSON.parse, and the resulting value is written back out with JSON.stringify: with a two-space indent for Format, with no whitespace at all for Minify. That has two practical consequences. First, validation is exactly as strict as the JSON grammar (RFC 8259): if it passes here, it is well-formed JSON as far as any standard parser is concerned. Second, the output is a re-serialization of the data, not a reflow of your original text, so a few things can come out spelled differently even though they mean the same thing.

Worked example

This 120-character order record, pasted in and formatted:

{"order":{"id":"A-1042","total":19.90,"items":[{"sku":"TEE-M","qty":2},{"sku":"MUG","qty":1}],"paid":false,"note":null}}

comes out as:

{
  "order": {
    "id": "A-1042",
    "total": 19.9,
    "items": [
      {
        "sku": "TEE-M",
        "qty": 2
      },
      {
        "sku": "MUG",
        "qty": 1
      }
    ],
    "paid": false,
    "note": null
  }
}

Notice 19.90 became 19.9. Numbers are parsed into values, and trailing zeros are not part of a number's value. Clicking Minify on the result gives back a single 119-character line: the same data, one character shorter because of that zero.

What changes when JSON is re-serialized

  • Big integers lose precision. Anything above 253 - 1 is rounded: 9007199254740993 becomes 9007199254740992, and a 30-digit integer turns into exponent notation such as 1.2345678901234568e+29.
  • Number spelling is normalized. 1.0 becomes 1, 1e3 becomes 1000, and -0 becomes 0.
  • Duplicate keys collapse. If an object contains "name" twice, only the last value survives, in the position of the first occurrence. Formatting is a quick way to find out which value your parser actually sees.
  • Escapes are decoded. \u00e9 comes out as é and \/ as /. Characters that must be escaped (quotes, backslashes, control characters) stay escaped.
  • Integer-like keys move first. Object keys that look like array indexes are ordered numerically ahead of other keys. That is a rule of JavaScript objects, not a choice made by this tool.

What it does not do

It reads one JSON value from a pasted string. It does not accept JSON5, comments, trailing commas or single quotes, and it does not open files directly, so for a large file open it in a text editor and paste. A file with one JSON object per line (JSON Lines or NDJSON) fails with Unexpected non-whitespace character after JSON at the start of line 2. Use the NDJSON Formatter for that. A byte order mark copied from a Windows-saved file also fails, as an "Unexpected token" on an invisible first character. There is no tree view, key sorting or indentation choice. For checking a document against a schema, the JSON Schema Validator is the better fit, and to compare two versions structurally, use JSON Diff.

Reading the error message

The error text comes straight from your browser's JSON parser, so it reads slightly differently in Chrome, Firefox and Safari. In Chromium-based browsers a trailing comma in [1,2,] is reported as Unexpected token ']', a trailing comma inside an object as Expected double-quoted property name with a position, and a literal line break inside a string as Bad control character in string literal. Empty input shows nothing; whitespace-only input is treated as empty. If the message points to a position, that is a character offset counted from zero, and the parser stopped on the character at or just after the real mistake.

Pasting a production payload into an online formatter is not always harmless. In November 2025, researchers at watchTowr reported pulling credentials out of pastes saved on two well-known JSON formatting sites; the exposure came from their save-and-share feature, not from formatting itself. This page has no save or share feature, and the text you paste is only held in the page until you close or reload it.

Frequently asked questions

Is my JSON sent to a server?

No. The formatter calls the browser's built-in JSON.parse and JSON.stringify on the text in the box. There is no upload step and no network request involved in formatting, so it is safe for API responses, config files and logs that contain tokens or customer data. Once the page has loaded it keeps working offline.

Why did a large number in my JSON change after formatting?

JavaScript stores every JSON number as a 64-bit floating-point value, which represents integers exactly only up to 9,007,199,254,740,991 (2^53 - 1). Larger integers are rounded to the nearest representable value, so 9007199254740993 comes back as 9007199254740992. If your data has 64-bit IDs (Twitter/X snowflakes, database bigints), keep them as strings in the JSON or format it with a tool that preserves the original text.

Can it format JSON with comments or trailing commas?

No. The parser follows the strict JSON grammar, so comments, trailing commas, single-quoted strings, unquoted keys and values like NaN or undefined are all errors. Those are JSON5 or JavaScript-object features, not JSON. Remove them, or if the input is a JavaScript object literal, convert it to real JSON first.

Can I choose tabs or 4-space indentation?

Not at the moment. Format always uses two spaces per level, which is the most common convention in package.json, API docs and most style guides. If you need tabs, a find-and-replace of leading double spaces in your editor will convert it.

Why did my keys change order?

Keys keep their original order with one exception defined by the JavaScript language: keys that look like non-negative integers (such as "2" or "10") are moved to the front in ascending numeric order. {"b":1,"10":2,"a":3,"2":4} formats as 2, 10, b, a. Data is not lost, but a diff against the original will show the move.

Does minifying change my data?

The values are the same, but the text may not be byte-identical to a hand-written minified version. Minify re-serializes the parsed value, so 19.90 becomes 19.9, 1e3 becomes 1000, escape sequences like \u00e9 become the literal character, and a duplicated key keeps only its last value. For almost every consumer that is equivalent JSON.

Get weekly dev tools and tips