Skip to content
KazamTools

JSON Formatter and Validator

Beautify, validate and minify JSON, with exact error locations and every number kept intact.

Checked as you type. Press Ctrl+Enter to format.

The second option accepts // and /* */ comments and trailing commas, like tsconfig.json or VS Code settings. Single quotes, unquoted keys, NaN and hex numbers are still errors. The result is always standard JSON.

Paste JSON above to check it and see it formatted.

Formatted JSON

How to use the JSON Formatter

  1. 1Paste your JSON into the box, or click Load sample to try it.
  2. 2Check the result: a green tick for valid JSON, or the exact line, column and a suggested fix for the first error.
  3. 3Choose Format with 2 spaces, 4 spaces or tabs, or Minify to strip all whitespace.
  4. 4Switch to Tree to explore nested data, then copy or download the result.

What the formatter does

JSON (JavaScript Object Notation) is plain text with a strict grammar, defined in RFC 8259. The tool reads your text one character at a time and checks it against that grammar. If everything is valid, it rebuilds the data with the layout you choose: indented with 2 spaces, 4 spaces or tabs, or minified onto a single line. If something is wrong, it stops at the first error and tells you the exact line and column, what it expected, and how to fix it.

Valid JSON has only six kinds of value:

Value Example Rules
Object {"name": "Ann"} Keys must be strings in double quotes
Array [1, 2, 3] Items separated by commas, no comma after the last
String "hello" Double quotes only; escape ", \ and line breaks
Number -12.5e3 No leading zeros, no +, no hex, no NaN
Boolean true Lowercase only
Null null Lowercase only

Why your numbers stay exactly as written

Most online formatters call the browser’s JSON.parse and then JSON.stringify. That round trip quietly changes data. JavaScript stores every number as a 64-bit float, which holds whole numbers exactly only up to:

253 − 1 = 9,007,199,254,740,991

So an ID such as 12345678901234567890 comes back as 12345678901234567000, and 1.50 becomes 1.5. This formatter never converts numbers. It copies each number and each string exactly as you typed it, escapes included, and only changes the whitespace between them. When it finds an integer beyond the safe limit it still keeps it, but shows a warning, because other programs reading the file with JSON.parse will round it.

Worked example: fixing a broken config

Paste this:

{
  "name": "shop",
  "port": 8080,
  "debug": true,
}

The validator reports Line 4, column 16: Trailing comma before }, with a caret under the comma after true. Delete that comma and the status turns to “Valid JSON · object with 3 keys”. Click Minify and you get {"name":"shop","port":8080,"debug":true}: 40 characters instead of 53, about 25% smaller.

Now change "port": 8080 to port: 8080. The error becomes Property names must be in double quotes, and the hint suggests writing "port":. Click Go to error to jump straight to the spot in the input box.

The most common JSON errors

  1. Trailing commas. JavaScript allows [1, 2, 3,]; JSON does not.
  2. Single quotes. 'text' is not valid; use "text".
  3. Unquoted keys. {name: "Ann"} must be {"name": "Ann"}.
  4. Comments. Standard JSON has no // or /* */ comments.
  5. Curly quotes. Copying from Word, Google Docs or a chat app can turn " into “ or ”. They look similar but are different characters.
  6. Missing commas between two properties, usually after adding a new line.
  7. Python values. True, False and None must be true, false and null.
  8. Two documents in one. {"a":1} {"b":2} is two values. Wrap them in an array, or treat the file as JSON Lines and check one line at a time.

If the first character is <, you probably pasted an HTML page, often an error page returned by an API instead of the data you expected.

Comments and trailing commas

Some files look like JSON but allow extras, for example tsconfig.json and VS Code settings (“JSONC”). Tick Allow comments and trailing commas to read them. The tool then skips // and /* */ comments and ignores a comma before } or ]. The output is always standard JSON, so the comments are removed. Single quotes, unquoted keys, NaN, Infinity and hex numbers still count as errors, because no common JSON-like format agrees on them.

Sorting keys and the tree view

Sort keys A→Z puts the properties of every object, at every level, in alphabetical order (by character code, so capital letters come before lowercase ones). Sorting makes two versions of the same data easy to compare: format both with sorted keys, then paste them into Text Compare to see only the real differences.

The Tree view shows the structure as collapsible branches. Each object shows how many keys it has and each array how many items, so you can find your way through a large API response without scrolling through thousands of lines. Big arrays load 100 items at a time.

Duplicate keys

{"id": 1, "id": 2} is technically allowed by the grammar, but most parsers keep only the last value, so the first one is silently lost. The validator accepts it and flags each repeat as a warning with its line and column.

For the full syntax rules and fixes for the error messages people hit most, see our guide on how to format JSON.

Large files and privacy

Everything runs in your browser, inside a background worker. Inputs larger than 1 MB are checked about a second after you stop typing, so the page stays responsive even with files of tens of megabytes. Nothing is uploaded, which matters because JSON often contains API keys, tokens and customer data.

Need to go further? Encode the result with the Base64 encoder, or create a checksum of it with the hash generator to confirm a copy matches the original.

Cite this tool

Using this tool in an essay, report or article? Copy a ready-made reference. Check your teacher's or publisher's style guide for small differences.

APA
KazamTools. (2026, October 21). JSON formatter. Retrieved October 30, 2026, from https://kazamtools.com/developer/json-formatter/
MLA
"JSON Formatter." KazamTools, 21 Oct. 2026, https://kazamtools.com/developer/json-formatter/. Accessed 30 Oct. 2026.
Chicago
KazamTools. "JSON Formatter." Last modified October 21, 2026. Accessed October 30, 2026. https://kazamtools.com/developer/json-formatter/.
Plain link
JSON Formatter (KazamTools): https://kazamtools.com/developer/json-formatter/
HTML link
<a href="https://kazamtools.com/developer/json-formatter/">JSON formatter</a> by KazamTools

Frequently asked questions

How do I format JSON?

Paste it into the box. The tool checks it as you type and shows a formatted copy with 2-space indentation. You can switch to 4 spaces or tabs, sort the keys, or minify it instead.

Why is my JSON invalid?

The most common causes are a trailing comma after the last item, single quotes instead of double quotes, property names without quotes, and comments. The validator points to the exact line and column and explains how to fix it.

Does JSON allow comments or trailing commas?

Standard JSON (RFC 8259) allows neither. Tick Allow comments and trailing commas to read files such as tsconfig.json; the result is then plain standard JSON without them.

Will formatting change my numbers?

No. Formatters built on JSON.parse round integers above 9,007,199,254,740,991 and turn 1.50 into 1.5. This one keeps every number and string exactly as written, and warns you about numbers JavaScript cannot store exactly.

Is my JSON sent to a server?

No. Everything runs in your browser, in a background worker, so API keys, tokens and customer data in your JSON never leave your device.

What is the difference between formatting and minifying JSON?

Formatting adds line breaks and indentation so people can read the data. Minifying removes all optional whitespace to make the file smaller to send or store.

Can it handle large JSON files?

Yes. Inputs over 1 MB are processed in the background so the page stays responsive, and the tree view loads big arrays 100 items at a time.

Guides

Was this tool helpful?