Free Developer Tool

JSON Formatter and Validator

Paste messy or minified JSON and get it formatted, validated and readable in one step. When something is wrong you get the exact line and column, the offending character, and a plain-English explanation instead of a cryptic parser message. Everything runs in your browser, so nothing you paste is ever uploaded.

  • Exact line and column on errors
  • Collapsible tree view
  • Duplicate key detection
  • Nothing leaves your browser

JSON formatter and validator tool

Your JSON

Waiting for input
Options

Result

Formatted JSON appears here.
  • Size-
  • Lines-
  • Keys-
  • Max depth-
  • Arrays-
  • Minified saving-

Why this JSON formatter finds the problem faster

Most online formatters hand back the raw browser error, which differs between Chrome, Firefox and Safari and rarely tells you where to look. This one runs its own parser, so the report is identical everywhere and points at the exact character.

Line, column and context

Errors come back with the line number, the column, the offending line printed out and a caret under the exact character that broke the parse.

Plain-English messages

Instead of "Unexpected token }", you get "Trailing comma before the closing brace" or "Property names must use double quotes", so the fix is obvious.

Duplicate key detection

Valid JSON can still be broken. Duplicate keys silently overwrite each other in every parser, and this tool flags them with the path where they occur.

Collapsible tree view

Switch from formatted text to an expandable tree to explore a large API response without scrolling through thousands of lines.

Format, minify, sort and measure

Choose 2, 3 or 4 spaces or tabs, sort keys alphabetically, and see size, line count, key count, nesting depth and the exact byte saving from minifying.

Fully private, nothing uploaded

All parsing happens in your browser with no libraries and no network calls, so API keys, tokens and customer records in your payload never leave the machine.

How to use the JSON formatter

Paste, read, fix, copy. Four steps, no account.

1

Paste your JSON

Drop in a minified API response, a config file or a log payload. Live update is on by default, so the result appears as you type or paste.

2

Read the status badge

Green means valid and formatted. Red means the parse failed, and the panel underneath shows the line, column and the character that caused it.

3

Set indent and key order

Pick 2, 3 or 4 spaces or tabs to match your project style, and sort keys alphabetically when you need to diff two payloads cleanly.

4

Copy, minify or download

Copy the formatted output straight to the clipboard, minify it back down for production, or download it as a .json file.

Common JSON errors and how to fix them

Almost every invalid payload falls into one of these categories. JSON is deliberately stricter than JavaScript object syntax, which is where most of the confusion comes from.

Common JSON syntax errors, causes and fixes
What you seeCauseFix
Unexpected token }A trailing comma after the last property or array itemDelete the final comma. JSON allows no trailing commas anywhere.
Unexpected token 'Single quotes around a string or keyReplace every single quote with a double quote.
Unexpected token in property nameAn unquoted key such as {name: "Ada"}Wrap every key in double quotes.
Unexpected token /A // or /* */ comment in the fileStrip the comments, or use JSONC or YAML if you need them.
Unexpected token NA JavaScript value like NaN, Infinity or undefinedUse null, or a string, or omit the property.
Unexpected end of inputA missing closing brace or bracket, often from a truncated downloadCount the brackets, or re-fetch the payload if it was cut short.
Bad control character in stringA raw newline or tab pasted inside a string literalEscape them as \n and \t.
Valid, but data is wrongDuplicate keys, where the last one silently winsRename or remove the duplicate. This tool flags them for you.

What a good formatter saves you

Reading raw JSON is a tax you pay every single day. Removing it compounds quickly.

Debugging in seconds, not minutes

A 4,000 character single-line API response is unreadable. Formatted with a tree view, the field you actually care about is three clicks away.

Clean diffs in code review

Sorting keys alphabetically before committing a config file turns a noisy 40-line diff into the two lines that genuinely changed.

Smaller payloads in production

Minifying strips whitespace with no data loss. The saving panel shows exactly how many bytes you get back before you ship.

No data leaving your machine

Pasting a payload with a bearer token into a server-side formatter is a real security incident. Client-side parsing removes that risk entirely.

JSON formatter FAQ

The questions developers ask most about formatting and validating JSON.

What does a JSON formatter actually do?

A JSON formatter parses your text, confirms it is valid JSON, and prints it back with consistent indentation and line breaks so the structure is visible. It does not change the data itself. Whitespace outside of strings has no meaning in JSON, so formatting and minifying produce byte-different but semantically identical documents.

Why is my JSON invalid when it looks like valid JavaScript?

JSON is a strict subset of JavaScript object syntax. It forbids trailing commas, single-quoted strings, unquoted keys, comments, and the values NaN, Infinity and undefined. Anything you can write in a .js file will not necessarily parse as JSON, and those five restrictions cause the overwhelming majority of failures.

Is this JSON validator safe for sensitive data?

Yes. Parsing, formatting and validation run entirely in your browser using local JavaScript. Nothing you paste is transmitted, logged or stored on any server, so payloads containing API keys, access tokens or personal data stay on your machine. Closing the tab discards everything.

Does JSON allow comments or trailing commas?

No to both. The JSON specification has no comment syntax and rejects a comma after the final element of an object or array. If you need comments in configuration files, use JSONC (supported by VS Code and TypeScript config), JSON5, or YAML, then strip or convert before any strict parser reads the file.

Are duplicate keys valid in JSON?

Technically the specification does not forbid them, but the behaviour is undefined and every mainstream parser keeps only the last occurrence, silently discarding the earlier ones. That makes duplicates one of the hardest JSON bugs to spot, because the document validates cleanly. This tool flags them so you catch the problem before it reaches production.

What is the difference between formatting and minifying JSON?

Formatting adds indentation and newlines so humans can read the structure. Minifying removes every byte of insignificant whitespace so machines can transfer it faster. The parsed data is identical either way, so format while you are debugging and minify whatever you send over the wire.

How large a file can this handle?

Because everything is processed locally, the practical limit is your device's memory rather than an upload cap. Payloads of a few megabytes format comfortably on a modern laptop. For very large files, turn off live update so the parse runs only when you press the format button.

Stop squinting at one-line API responses

Paste the payload, read the structure, and if it breaks you will know the line, the column and the reason in one glance. No upload, no account, no waiting on a round trip to someone else's server.

Open the JSON formatter
Scroll to Top