# JSON Formatter & Validator

> Format, validate and minify JSON in your browser. Exact line and column for errors, one-click fixes for trailing commas and quotes, sort keys. Nothing uploaded.

Canonical: https://cromagnon.app/tools/json-formatter
Last updated: 2026-10-25

- Category: Developer
- Formats: JSON
- Use it: https://cromagnon.app/tools/json-formatter (free, runs in the browser)

## What it does

Paste JSON to check that it's valid and make it readable, or squeeze it into one line. If something is wrong, you get the line, the column and a plain explanation, and common mistakes can be fixed in one click. Numbers are kept exactly as you typed them, even very long IDs.

## How to use it

1. Paste your JSON into the Input box (or press Sample to try one).
2. Choose Pretty with 2, 4 or 8 spaces or a tab, or Minify for one line. Tick sort keys A–Z if you want the keys in order.
3. Read the status line: it says the JSON is valid and shows how many keys, how deep, and the size before and after.
4. If there's an error, read the line and column, or press Fix common mistakes. Then copy or download the result.

Tip: An error like “Unexpected token” usually means a missing comma, an extra comma before } or ], or single quotes instead of double quotes. Fix common mistakes handles all three.

## What makes JSON valid

JSON is stricter than the JavaScript it looks like. Most “invalid JSON” errors come from one of a handful of rules.

- **Double quotes only**: Keys and text need double quotes: {"name": "Ali"}. Single quotes and unquoted keys aren't allowed.
- **No trailing commas**: [1, 2, 3,] and {"a": 1,} are errors; remove the last comma.
- **No comments**: // and /* */ comments aren't part of JSON. Config files that allow them (JSONC, JSON5) aren't plain JSON.
- **Lowercase literals**: true, false and null, never True, False, None or undefined.
- **Text must be escaped**: Quotes, backslashes and line breaks inside text are written as \", \\ and \n.

## Fix common mistakes in one click

When the JSON won't parse but looks like it came from code or a config file, a Fix common mistakes button appears. It removes // and /* */ comments, deletes trailing commas, turns single-quoted strings into double-quoted ones, puts quotes around bare keys, and changes Python's True, False and None into true, false and null.

The fix only touches what's outside your text values, so a URL such as "https://example.com" isn't mistaken for a comment. Check the result: the status line tells you straight away whether it's now valid.

## Pretty, minified and sorted: when to use which

- **Pretty**: For reading, reviewing and committing to a repository. Two spaces is the most common style; tabs suit editors set to show them wide.
- **Minified**: For sending over a network or storing: no spaces or line breaks, so the payload is smaller. The status line shows the saving.
- **Sorted keys**: For comparing two JSON files: with keys in the same order, a text diff shows only real changes.

## Why big numbers stay exact here

Many online formatters turn your JSON into JavaScript numbers and back, which silently changes long IDs: 12345678901234567890 becomes 12345678901234567000, and 1.50 becomes 1.5. This formatter re-indents the text itself, so every digit you pasted is the digit you get.

The only exception is sort keys, which has to read the values; very long numbers may then be rounded, so leave it off for data with big IDs.

## Reading a JSON error message

Every error here names a line and a column, then the likely cause. Three examples:

- **Line 4, column 1: There's a comma before a closing bracket**: The line above ends with a comma but nothing follows it. Delete that comma.
- **Line 1, column 2: JSON needs double quotes**: The text uses 'single quotes'. Replace them, or press Fix common mistakes.
- **The JSON ends too early**: A closing } or ] or a closing quote is missing, often because the text was cut off when copying.

## Where you'll meet JSON

JSON is the language of web APIs (almost every REST API sends and receives it), of configuration files such as package.json and tsconfig.json, of browser storage, and of exports from tools like Postman, Firebase and MongoDB.

Log files in the JSON Lines format put one JSON object on each line; those lines are separate documents, so paste one line at a time here, or use the Line Sorter to tidy them first.

## Tips

- **Validate API responses fast**: Copy a response from your browser's network tab and paste it here to see whether the server returned real JSON or an error page.
- **Find the broken line in a huge file**: The error gives the line and column; most editors jump to a line with Ctrl + G.
- **Check the size saving**: Minify and read the before → after sizes to see what removing whitespace saves.
- **Use it for config files**: package.json, tsconfig.json and .eslintrc files are JSON; a bad comma there stops a build.
- **Sort before you compare**: Sort keys on both files, then paste them into the Text Diff Checker to see only real differences.
- **Keep secrets local**: Because nothing is uploaded, it's safe to format JSON that contains tokens or customer data.

## Questions

### Why is my JSON invalid?

JSON needs double quotes around keys and text, no comments and no comma after the last item. The error message gives the line, the column and the likely cause.

### What is the difference between pretty and minified JSON?

Pretty JSON adds line breaks and indentation for people to read; minified JSON removes them so files are smaller and faster to send.

### Can I fix JSON with comments or trailing commas?

Yes. Press Fix common mistakes: comments, trailing commas, single quotes, unquoted keys and Python literals are corrected.

### Does it change my numbers?

No. The text is re-indented as it is, so long IDs and decimals like 1.50 come out exactly as typed (unless you sort keys).

### Can I format JSON with tabs?

Yes. Choose Tab in the Indent list.

### Is JSON the same as a JavaScript object?

No. JSON is a text format with stricter rules: double quotes only, no comments, no trailing commas, no functions or undefined. A JavaScript object can hold things JSON can't.

### How big a file can I format?

Files of several megabytes format in a moment, because everything runs on your computer. Very large files depend on your device's memory.

### Is my data uploaded?

No. The tool runs in your browser; what you paste or open never leaves your device and nothing is stored on a server.

## Related

- [YAML ↔ JSON Converter](https://cromagnon.app/tools/yaml-json)
- [JSON ↔ CSV Converter](https://cromagnon.app/tools/json-csv)
- [JWT Decoder](https://cromagnon.app/tools/jwt-decoder)
- [Text Diff Checker](https://cromagnon.app/tools/text-diff)
- [All tools](https://cromagnon.app/tools)
