JSON Formatter and Validator

Paste JSON or open a file to format and validate it instantly, with warnings for duplicate keys and large numbers that lose precision. Everything runs in your browser — no data is uploaded.

About JSON Formatter & Validator

JSON is the everyday format for passing data between websites, apps and APIs, but it often arrives as one endless line, or with a missing comma that breaks everything downstream. This tool handles both problems. Paste your JSON into the box or open a file from your device, then press Format to pretty-print it with two spaces, four spaces or tabs per level, or Minify to strip all whitespace into a single compact line. The result replaces the text in the same box, and a status line underneath turns green when the JSON is valid or shows the error with its line and column when it is not. You are also warned about duplicate keys and large numbers that lose precision, and you can copy the result or download it as a file.

Validation uses your browser's built-in JSON parser, which follows the JSON standard strictly: no comments, no trailing commas, no single-quoted strings. The error message comes straight from the browser and usually points to roughly where the problem is. It is handy for developers, API testers and anyone editing config files, and it runs entirely in your browser, so payloads that contain tokens or customer data are never sent to a server.

Why use it

  • Readable two-space indentation for deeply nested data.
  • One-click minify to shrink payloads before sending or storing them.
  • Instant validation with the browser's own error message.
  • Copy and Clear buttons to keep the workflow quick.
  • Your data never leaves your device, which matters for sensitive API responses.

How to use

  1. Paste your JSON

    Drop an API response, a config file's contents or a log snippet into the box.

  2. Format or Minify

    Format adds indentation and line breaks; Minify removes every unnecessary space and newline.

  3. Check the status

    Valid JSON shows a success message and the box is replaced with the result. Invalid JSON shows an error and your text is left unchanged.

  4. Copy or clear

    Press Copy to put the result on your clipboard, or Clear to empty the box and start over.

Examples

Reading an API response

A store API returns 3,000 characters on one line. Formatted, its structure is obvious, and you can see that price lives inside the variants object, not at the top level.

Catching a trailing comma

A config file has a list ending in "blue", followed by the closing bracket. Format reports an error; delete the last comma and it validates.

Preparing a payload

A 40-line formatted object needs to go into an environment variable or an HTTP request body. Minify turns it into one line with no spaces, ready to copy.

Fixing quotes from JavaScript

You copied {'name': 'Ali'} from JavaScript code. The validator rejects it because JSON requires double quotes; change it to {"name": "Ali"}.

Common JSON mistakes
MistakeInvalidValid
Trailing comma[1, 2, 3,][1, 2, 3]
Single quotes{'a': 1}{"a": 1}
Unquoted key{a: 1}{"a": 1}
Comments{"a": 1 // note}{"a": 1}
undefined value{"a": undefined}{"a": null}

Tips

  • The error message gives a line and column; look there or just before it, as the culprit is usually the previous comma or bracket.
  • Very large integers, such as IDs longer than about 15 digits, can lose their last digits when parsed. Store them as strings.
  • If a key appears twice in the same object you get a warning, because only the last value survives formatting.
  • Escaped Unicode like \u00e9 is written out as the actual character after formatting; the meaning is unchanged.
  • Keep a copy of your original text before experimenting, since the result overwrites the box.

Formatting and validation run in your browser with JavaScript; your JSON is never sent to a server.

Frequently asked questions

How do I know if my JSON is invalid?

Press Format or Minify. Invalid JSON produces a red message starting with Error, followed by the browser's description, which usually includes the approximate position.

What's the difference between Format and Minify?

Format adds line breaks and two-space indentation for readability. Minify removes all unnecessary whitespace to make the data as small as possible. The data itself is identical.

Is my data sent to a server?

No. The tool uses your browser's built-in parser, so the data never leaves your device.

Does it accept comments or trailing commas?

No. It follows strict JSON, where comments and trailing commas are not allowed, so you will see an error. Remove them, or use a JSON5-aware tool if you need that syntax.

Why did a large number change?

JavaScript numbers have limited precision, so integers beyond about 9 quadrillion are rounded. Wrap long IDs in quotes so they stay as strings.

Does formatting change key order?

Order is generally kept, but keys that are whole numbers, such as "1" or "20", move to the start of the object in ascending order. That is standard JavaScript behavior.

Can it fix broken JSON automatically?

No. It detects the problem and shows the message; fixing is manual. The common-mistakes table on this page covers the usual causes.

Does it handle non-English text?

Yes. Arabic, accented or any Unicode text is preserved, and \u escape sequences are shown as readable characters after formatting.

Can I choose the indentation size?

Yes. Choose 2 spaces, 4 spaces or Tab from the indentation menu before formatting.

Can I upload a .json file?

Yes. Use the open-file button to pick a .json file from your device; its contents appear in the box, ready to format and download.

What does Clear do?

It empties the box and hides the status message so you can start fresh.

Can I convert JSON to CSV or YAML?

Yes. Adwaty's developer tools section includes JSON to CSV, JSON to YAML and the reverse conversions.

Last updated:

Share this tool:WhatsAppXTelegram