# JSON formatter & validator

Pretty-print, minify and validate JSON – with the exact error location and clear hints instead of cryptic parser messages.

Use online: https://skriptbox.com/en/tools/json-formatter

> Your JSON is processed only in your browser and is never transmitted – opened files included.

## How it works

1. **Paste JSON** – Paste JSON, drop a file onto the field or open one. It is checked right away, without any upload.
2. **Fix errors** – For invalid JSON you see the line, column and highlighted spot plus a hint, such as a stray comma or missing quotes.
3. **Use the result** – Pick an indentation or minify, sort the keys if needed, then copy the result or download it as a file.

## JSON rules in a nutshell

JSON is stricter than it looks. A document consists of exactly one value, usually an object `{ … }` or an array `[ … ]`. Only these values are allowed:

- Strings in **double** quotes, e.g. `"Cologne"`; line breaks inside them written as `\n`, backslashes as `\\`
- Numbers such as `42`, `-3.14` or `1e10` – no leading zeros, no `+`, a dot as decimal separator
- `true`, `false` and `null`, always lowercase
- Objects and arrays, nested as deeply as you like

Keys are always in double quotes. Comments, a comma after the last item, `undefined`, `NaN` and `Infinity` don't exist in JSON. Spaces and line breaks between the parts, on the other hand, are up to you.


## Where common errors come from

Most invalid JSON is really something else:

- **A JavaScript object instead of JSON:** Copied from source code, keys are often unquoted, strings use single quotes and there's a trailing comma.
- **Python output:** `print()` on a dictionary gives you `'name'`, `True` and `None`. Valid JSON comes from `json.dumps()`.
- **Copied from Word, email or chat:** Straight quotes are often turned into curly ones like “ and ” – to a parser, those are just ordinary characters.
- **Config files with comments:** Many programs read an extended format (see below) that a strict parser rejects.

In these cases the validator shows not just the location but also the likely cause.


## Large numbers and duplicate keys

JSON itself puts no limit on numbers, but JavaScript and many other languages store them as 64-bit floating point. Integers above 2⁵³ (9,007,199,254,740,992) get rounded: `9007199254740993` is read as `9007199254740992`. Long IDs, e.g. from databases or social media APIs, are therefore better sent as strings: `"id": "9007199254740993"`. This tool keeps the original digits when formatting and warns you about affected numbers.

If a key appears more than once in the same object, the behavior is undefined. JavaScript, Python and PHP silently keep the last value, while some strict parsers stop with an error. Duplicate keys are almost always a mistake, so they're flagged here.


## Format or minify?

Formatted, indented JSON is meant for humans: for reading, debugging and for files under version control where you want readable diffs. Minified JSON without whitespace is smaller and suits API responses, database fields or environment variables. Neither changes the content, and if the data is compressed with gzip or Brotli anyway, the size difference is small.

Don't confuse JSON with its extensions: **JSONC** (JSON with Comments) allows comments and is used, for example, in VS Code settings and `tsconfig.json`. **JSON5** additionally allows single quotes, unquoted keys and trailing commas. Neither is valid JSON, and both are reported as errors here.


## Frequently asked questions

### Are comments allowed in JSON?

No. JSON supports neither `//` nor `/* … */`. If you need notes, store them in a separate field such as `"_comment": "…"`, or use a format like JSONC that only certain programs read.


### Why is my JSON invalid?

The most common causes are a comma after the last item, single or curly quotes, unquoted keys and comments. Paste your text above – the validator shows the line, column and likely cause.


### What's the difference between JSON and a JavaScript object?

JSON is a text format for exchanging data; a JavaScript object is a data structure inside a program. Object literals in source code are more relaxed: unquoted keys, single quotes, comments, trailing commas, functions and `undefined` are allowed there but not in JSON. You convert between the two with `JSON.stringify()` and `JSON.parse()`.


### How do I format JSON in VS Code or on the command line?

In VS Code, open the file and run “Format Document” (Windows `Shift+Alt+F`, macOS `Shift+Option+F`, Linux `Ctrl+Shift+I`). On the command line, use `python3 -m json.tool file.json` or `jq . file.json`; `jq -c . file.json` minifies.


### Is my data uploaded?

No. Validating, formatting and opening files all happen in your browser. That makes the tool safe to use for confidential data such as API responses containing customer records.


### Does formatting change my data?

No, only whitespace and line breaks change. Numbers keep every digit, and the key order stays the same unless you turn on sorting. Escape sequences like `é` appear as readable characters (é) in the result.



## Related tools

- [Table to HTML](https://skriptbox.com/en/tools/table-to-html.md) – Convert tables from Excel, Google Sheets or CSV into clean, accessible HTML.
- [JWT Debugger](https://skriptbox.com/en/tools/jwt-debugger.md) – Decode JSON Web Tokens, verify signatures (HMAC, RSA, ECDSA, EdDSA) and create your own tokens – nothing is transmitted.
- [Base64 Encoder & Decoder](https://skriptbox.com/en/tools/base64-encoder.md) – Encode and decode text and files as Base64 – UTF-8, base64url and data URIs for CSS and HTML, with validation and preview. No upload.
