JSON Formatter

Paste JSON and this free formatter indents, validates and highlights it as you type. Errors come with the line, the column and a plain-English reason, plus a Fix it button for trailing commas, single quotes and comments. Numbers and keys come out exactly as you pasted them, and nothing leaves your browser.

Indent
Output
{
  "name": "AEON Toolhub",
  "tools": 25,
  "free": true,
  "categories": [
    "productivity",
    "text",
    "developer"
  ],
  "owner": {
    "handle": "oiurireis"
  }
}
Size 174 BKeys 6Depth 2

Why is my JSON invalid when it looks fine?

Usually because it was written the JavaScript or Python way. JSON is stricter than the code it came from, and five slips cause most of the errors:

  • A trailing comma after the last item: [1, 2, 3,]
  • Single quotes: 'name' instead of "name"
  • Unquoted keys: {name: "Ana"}
  • Comments, like // the brand, which JSON has no concept of
  • Python values: True, False and None instead of true, false and null

The browser only reports a character offset, such as position 412, which is useless in a long file. This formatter turns it into a line and column, prints that line with a caret under the character, and says what is wrong in plain words. Click Try broken JSON to see it on this input:

{
  name: 'AEON Toolhub', // the brand
  tools: [1, 2, 3,],
  free: True,
}

The tool answers "Property names need double quotes" on line 2, column 3. Its Fix it button lists what it will change before you click it, here unquoted keys, single quotes, comments, trailing commas and Python values, and it only appears when the repaired text is valid JSON.

What does "Unexpected token < in JSON at position 0" mean?

It means the text is not JSON at all. A < at the very start is the beginning of an HTML page: the address you called returned a web page or an error page, such as a 404, a 502 or a login screen, instead of data. Paste it here and the tool says exactly that. Two close relatives:

  • "Unexpected end of JSON input": the response was empty, or cut off before its last } or ].
  • An unexpected token you cannot see at position 0: an invisible byte order mark, common in files saved by Windows programs. Fix it removes it.

Does formatting change your data?

Not here. A common way to build a formatter is to read the JSON into JavaScript values and write them back out, and JavaScript numbers are only exact up to 9,007,199,254,740,991. We pasted the same text into that approach and into this tool:

You pasteRead into JavaScript and written backThis formatter
123456789012345678912345678901234568001234567890123456789
1.101.11.10
"café""café""café"
{"a": 1, "a": 2}{"a": 2}both keys, flagged

This formatter works from your text instead. It only changes spaces and line breaks, so 64-bit IDs, prices and escaped characters come out exactly as you pasted them. A key that appears twice in the same object is kept and marked as a duplicate under the output, because most parsers silently keep only the last one. Sort keys A-Z is the one option that moves anything: it reorders object keys, never values and never arrays.

Is it safe to paste API keys into an online JSON formatter?

It depends on where the formatting happens. In November 2025, security researchers at watchTowr reported more than 80,000 pastes exposed by two popular online formatters, including passwords, cloud keys and private keys. The cause was a save-and-share feature whose links could be guessed.

This formatter has no save or share feature and runs in your browser, so what you paste is not sent anywhere. You can check it yourself: open your browser's developer tools, go to the Network tab, paste your JSON, and no request leaves the page. For production secrets, the safest habit is still to swap real keys for placeholders before pasting them into any website.

When is a local tool better?

When the file is already on your machine, these do the same job without a browser tab:

  • VS Code: run Format Document with Shift + Alt + F on Windows, Shift + Option + F on macOS, or Ctrl + Shift + I on Linux.
  • jq: jq . data.json pretty-prints and jq -c . data.json minifies.
  • Python: python -m json.tool data.json, with --sort-keys to order the keys.

A website wins when you only have the text, such as a response copied from logs or a chat, or when you want the error explained and fixed rather than just reported.

How much does minifying JSON save?

Less than most people expect on a flat file. In our test, minifying a GitHub API response indented with two spaces saved 10 to 12%, while a deeply nested package-lock.json saved 23%, since every level of nesting adds indentation to strip. From a four-space file the savings rise to 15 to 35%. The tool shows the exact figure for your file under the output, next to its size, key count and nesting depth. If the JSON travels over HTTP with gzip or Brotli, most of that whitespace is compressed away anyway, so minifying matters most where JSON is stored or logged as it is.

Frequently asked questions

What does "Unexpected token < in JSON at position 0" mean?

It means the text is HTML, not JSON. The address you requested returned a web page, often an error page such as a 404, a 502 or a login screen, instead of data. Check the status code and the Content-Type of the response. Paste the text into this formatter and it tells you it is HTML.

What does "Unexpected end of JSON input" mean?

The parser reached the end of the text while it still expected more, so a closing brace, bracket or quote is missing. It usually means the response was empty or cut off, for example by a timeout or a size limit. This formatter explains it in plain words and usually points to where the text stops.

Why is my JSON invalid when it looks fine?

The most common causes are trailing commas after the last item, single quotes instead of double quotes, keys without quotes, or comments, none of which strict JSON allows. JavaScript object syntax is more relaxed than JSON, so text copied from code often needs these small fixes before it will parse.

Can JSON have comments or trailing commas?

No. Standard JSON allows neither, which is why a config file that works in your editor can fail somewhere else. Formats such as JSONC and JSON5 accept comments and trailing commas, but a strict parser rejects them. The Fix it button here removes both and lists the changes before it applies them.

Why did my big numbers change after formatting JSON?

Because the tool turned them into JavaScript numbers, which are exact only up to 9,007,199,254,740,991. Larger integers, like 64-bit database or social media IDs, get rounded, so 1234567890123456789 becomes 1234567890123456800. This formatter keeps every number as the text you pasted, so IDs stay exact in every indentation mode.

What happens to duplicate keys in JSON?

The JSON standard says the keys in an object should be unique but does not forbid repeats, and most parsers silently keep only the last value. That can hide a real bug. This formatter keeps both entries in their original order and shows a duplicate key warning under the result, so you decide which one is right.

Is it safe to paste API keys into a JSON formatter?

Only if the formatter never sends or stores what you paste. In 2025, researchers found more than 80,000 saved pastes exposed by two popular online formatters. This one runs in your browser and has no save or share feature. You can confirm it in the Network tab of your developer tools: pasting sends no request.

How do I format JSON in VS Code?

Open the .json file and run Format Document: Shift + Alt + F on Windows, Shift + Option + F on macOS, or Ctrl + Shift + I on Linux. If nothing happens, check that the language mode in the status bar says JSON. For text that is only on your clipboard, pasting it here is faster.

Can I sort JSON keys alphabetically?

Yes. Turn on "Sort keys A-Z" and every object is rewritten with its keys in alphabetical order, recursively, while arrays keep their original order. It makes two versions of a config or an API response much easier to compare in a diff, since key order stops being noise.

Can it handle a large JSON file?

Yes. Validation uses the browser parser and the formatting works straight from your text, so files of several megabytes are formatted in a fraction of a second. Syntax colouring switches off automatically above roughly 150 KB so the page stays responsive, while formatting, validation, copy and download keep working normally.

Rate JSON Formatter & help shape it

This tool is free and still growing. Tell us what works, what you would change, and what is missing. Your feedback is what decides what we build next.

Your rating
Tap a star to start

Built and tested by the ÆON Toolhub team. Last updated: October 18, 2026. How we test our tools