Skip to content
Sealpaste

Delete all recent work?

This removes the 0 items saved in this browser. Your settings stay.

Stop saving recent work?

New work won't be saved in this browser. The 0 items already saved can stay or go.

JSON Formatter

Input

Paste JSON, or

CtrlV paste · Ctrl↵ run now

Result
Ready
Ln 1, Col 1
Runs in your browser. Nothing you paste is uploaded unless you share it.

Pretty-print JSON with every number exact, or repair broken JSON: quotes, commas, comments

Paste messy or minified JSON and get it indented and easy to read. Every number stays as written, and a click on a line shows its path.

How to use it

  1. Paste JSON, drop a .json file on the input, or click Try sample.
  2. Pick the indent (2, 3, 4 or Tab) and turn on Sort keys to put the keys of every object in A to Z order.
  3. The result appears as you paste. Click any line of the result to see its path, such as $.items[0].price.
  4. Not quite JSON? Turn on Repair: quotes, commas, comments, unquoted keys and Python’s True and None are fixed, each change listed with its line.
  5. Copy the result, or download it as formatted.json.

Examples

Pretty-print an API response

Input
{"user":{"id":7,"tags":["a","b"]},"ok":true}
Result
{
  "user": {
    "id": 7,
    "tags": [
      "a",
      "b"
    ]
  },
  "ok": true
}

Sort keys, keep the numbers

Input
{"price": 1.50, "id": 12345678901234567890}
Result
{
  "id": 12345678901234567890,
  "price": 1.50
}

A formatter built on JSON.parse prints 12345678901234567000 and 1.5 here.

Repair a JavaScript object

Input
{id: 7, name: 'Ada', tags: ['a', 'b',], active: True}
Result
{
  "id": 7,
  "name": "Ada",
  "tags": [
    "a",
    "b"
  ],
  "active": true
}

With Repair on; the list above the result names each of the 9 changes, such as "Line 1, column 2: Put quotes around the key id."

What formatting changes

Only whitespace: a line break after each value and the indent you pick. Strings, numbers and the order of keys stay as they were, unless you turn on Sort keys.

  • Sort keys orders the keys inside every object, at every depth. Arrays keep their order, because in JSON their order is part of the data.
  • Numbers are copied as written: 1.50 stays 1.50 and 12345678901234567890 keeps all 20 digits.
  • Duplicate keys are kept, both of them, in the order they came.
  • Minify does the opposite and puts everything on one line.

Repairing almost-JSON

Repair reads text that is nearly JSON, such as a JavaScript object, a Python dict, JSON5, a log line or a response cut off at the end, and writes JSON. It runs only when the text doesn’t parse, and lists every change with its line and column, so nothing is changed without you seeing it.

  • Single, backtick and curly quotes become double quotes; keys without quotes get them.
  • Missing commas and colons are added; trailing and doubled commas, // and /* */ comments are removed.
  • True, False and None become true, false and null; NaN, Infinity and undefined, which JSON has no way to write, become null.
  • Unclosed strings, arrays and objects are closed; a ``` code fence or a JSONP callback(…) around the value is taken off; several values in a row go into one array.
  • Numbers keep their digits; only +1, .5, 5. and hex like 0x1F are rewritten as JSON writes them.

Formatting in code

Every language formats JSON in a line or two, but they don’t all keep numbers the same way: JSON.stringify reads every number as a double, so large IDs lose digits and trailing zeros go; Python keeps whole numbers exact but writes 1.50 as 1.5; Go’s json.Indent and jq 1.7 and later keep both as written. This page keeps every number as written.

JSON.stringify(JSON.parse(text), null, 2);
// numbers become doubles: 12345678901234567890 → 12345678901234567000, 1.50 → 1.5

Sources: jq 1.7 manual: number precision, Python docs: json.tool

Reading big JSON

Formatting runs in a background worker, so the page keeps answering while a large file is read. The result draws only the lines on screen, so a long file scrolls as smoothly as a short one.

A very long line is shortened on screen with a note of how much is left; Copy and Download give the whole text.

Keys and tokens in the JSON

API responses and config files often hold credentials. When the result has something that looks like one (an AWS or Stripe key, a GitHub token, a JWT, a password field), a bar above it names the line and offers Redact, which replaces the value in the input before you share it.

Questions

Is my JSON uploaded?
No. Everything runs in your browser, so your JSON stays on your device. Nothing you paste is uploaded unless you share a result, which is locked with your password first. We don’t save or log what you paste, so API responses with tokens or customer data don’t reach us.
Why do my big numbers stay exact here?
Most formatters read JSON with JavaScript’s JSON.parse, which turns 12345678901234567890 into 12345678901234567000 and 1.50 into 1.5. This formatter keeps the digits of each number as written, so 64-bit IDs and prices are not changed.
Does Sort keys change my data?
Only the order of keys inside objects, which JSON gives no meaning to (RFC 8259). Arrays keep their order.
What happens if my JSON is not valid?
It is not formatted. You see the line, the column and the reason, with the lines around it, and Show in input puts the cursor on the spot. Turn on Repair to have quotes, commas and comments fixed for you, each change listed.
How large a file can I format?
Up to 10 MB, counted in bytes; a larger file is not read, which keeps the page quick on phones too.

Related tools