Tools/Developer Tools/JSON Formatter

JSON Formatter & Validator – Beautify JSON Online

Format, minify and validate JSON. Upload a .json file or paste text; invalid JSON shows the parser's error with the line and column where it stopped.

If this tool isn’t working as expected, please take a screenshot of the error and report the problem here so we can investigate and improve it.

About this tool

This JSON formatter beautifies, minifies and validates JSON in one place. Paste text or upload a .json file and the page parses it with the browser's own JSON.parse, then prints it back indented with two or four spaces - or on one line with Minify.

If the text isn't valid JSON, it works as a JSON validator: the page shows the parser's message with the line and column where parsing gave up, and clears the previous output so you never read a stale result. Everything runs in your browser; the text and any file you choose are not sent to a server.

Because the check is JSON.parse itself, it applies the same strict JSON grammar (RFC 8259) as the parser in your own code. It also means the output is JSON.stringify's re-serialization of what was parsed, not your original text with spaces added - the first FAQ lists the few values that can change on the way through.

How to Use JSON Formatter

Paste or Upload JSON

Paste JSON into the box, or choose a .json file with Upload JSON.

Format or Minify

Format indents with 2 or 4 spaces; Minify puts everything on one line.

Read Any Error

Invalid JSON shows the parser's message with the line and column where it stopped.

Copy or Download

Copy the result, or download it as a .json file.

Common Workflows

Reading an API response

Copy the body from your browser's Network tab or an API client, paste it and click Format. Each nesting level gets one indent step.

Checking a config before you deploy

Paste package.json or any JSON config. If it's invalid, the error points at the line where parsing stopped, which is quicker than finding out after a failed deploy.

Reading a webhook or tool-call payload

Webhook bodies and the arguments an AI tool call returns often arrive as one compact line. Formatting shows whether the fields your handler expects are really there.

Comparing two payloads

Minify both versions and paste them into the Text Compare tool. Whitespace differences disappear, so only real changes show - though a different key order still counts as a change.

Moving records into a spreadsheet

Once an array of objects parses, take it to the JSON to CSV Converter or the JSON to Excel Converter.

Examples

Format a compact API response

Raw JSON

{"user":{"name":"Aisha","active":true},"role":"admin"}

Formatted JSON

{
  "user": {
    "name": "Aisha",
    "active": true
  },
  "role": "admin"
}

Minify takes the formatted output back to the single-line form.

Find a trailing comma

Broken Input

{"a":1,"b":2,}

Error shown

Line 1, column 14: Expected double-quoted property name

The wording comes from your browser's JSON parser, so it differs between browsers; the line and column appear whenever the browser reports a position. Here the parser stops at the closing brace, because after a comma it expected another key.

A value that changes on the way through

Input

{"id":12345678901234567890,"price":1.50}

Formatted output

{
  "id": 12345678901234567000,
  "price": 1.5
}

JSON.parse reads every number as a 64-bit float, so integers above 9,007,199,254,740,991 lose their last digits and 1.50 prints as 1.5. If the exact digits matter, as with large IDs, keep the original text rather than the formatted copy.

Common Mistakes

Problem

Trailing commas

Solution

A comma after the last item - {"a":1,} - is legal in a JavaScript object literal but not in JSON. Delete the comma after the final item.

Problem

The wrong kind of quotes

Solution

JSON needs straight double quotes around every key and string. Single quotes ({'a':1}), unquoted keys ({a:1}) and the curly quotes that Word, Google Docs and some chat apps insert are all rejected.

Problem

Pasting a config that contains comments

Solution

tsconfig.json and similar files are JSONC: comments and trailing commas are legal there, but JSON.parse rejects them, so this page flags them as invalid. Strip them first.

Limitations

It reports the error but doesn't repair it

Fix the syntax yourself, then format again. The page doesn't guess at what the structure should have been.

The position is where the parser stopped

For a missing comma, the reported spot is the start of the next item. Chrome and Edge report no position for some errors, such as a misspelled true, false or null, and show only the message.

Standard JSON only

No JSON5 or JSONC (comments, trailing commas, single quotes). Line-delimited JSON, with one object per line, isn't a single JSON value either, so it fails after the first line.

FAQs

These cover why valid-looking JSON fails to parse, what validation does and doesn't check, and what formatting does to your data.

Why does JSON that looks correct fail to parse?

Usually something that looks right but isn't: curly quotes pasted from a document, a byte-order mark at the start of a file, a raw line break or tab inside a string (they have to be written \n and \t), a number with a leading zero or a leading dot (01, .5), or NaN, Infinity and undefined, which JSON doesn't have. The line and column in the error message usually lead you straight to it.

Does it validate against a JSON Schema?

No. Validation here means checking that the text is valid JSON - correct syntax and nothing else. The page doesn't compare fields, types or required keys against a JSON Schema, and it doesn't repair errors. Use a schema validator for that.

What is the difference between JSON and a JavaScript object?

JSON is a text format with stricter rules than a JavaScript object literal: keys must be double-quoted strings, values can't be undefined, functions or NaN, and trailing commas and comments aren't allowed. Output from JSON.stringify() is always valid JSON, but a hand-written object literal often isn't.

Does formatting or minifying change my data?

The structure and values stay the same, but the text is re-created by JSON.stringify, so a few things are normalized. Numbers are read as 64-bit floats: integers above 9,007,199,254,740,991 lose digits, 1.50 becomes 1.5 and 1e2 becomes 100. Duplicate keys collapse to the last value, escapes such as \u00e9 print as the character é, and keys that look like whole numbers move to the front in ascending order. If you need the original text byte for byte, keep it.

Is it safe to paste API keys or private data?

Formatting and validation use JSON.parse and JSON.stringify in your browser, and nothing sends your JSON anywhere. You can check this yourself: open your browser's DevTools Network tab, paste and click Format, and look for a request that contains your text - there won't be one. Even so, a live secret is a secret - use test credentials where you can.

Is there a limit on file size?

The tool sets no limit of its own. The file is read and parsed in your browser's memory, so very large files are limited by your device and browser rather than by the page.

How do I open and view a .json file?

Choose Upload JSON and pick the file, or paste its contents, then press Format - or turn on Auto format to format as soon as it loads. The formatted text is a readable view of the file, and the file is read in your browser and isn't uploaded anywhere.

Get more tools like this

Leave your email so we can prioritize similar tools and updates.