WebToolX

Command Palette

Search for a command to run...

Developer Tools

JSON Formatter & Validator

Format, minify, and validate JSON instantly in your browser. Pretty-print with 2/4 spaces or tabs, spot syntax errors with exact line numbers.

Paste JSON above to format, minify, or validate it.

JSON Formatter & Validator — Format, Minify, and Debug JSON Instantly

JSON (JavaScript Object Notation) is the de-facto data interchange format for APIs, configuration files, and web applications. But raw JSON straight out of an API response or a log file is often a single dense line of characters — nearly impossible to read at a glance. This JSON Formatter takes that compact blob, parses it, and re-serialises it with clean indentation and line breaks so the structure jumps out immediately. It works the other way too: paste a sprawling pretty-printed config and click Minify to produce the tightest representation for a network request or an environment variable.

How to Use the JSON Formatter

  • Paste your JSON into the input area. A live badge tells you instantly whether the input is valid or not.
  • Click Format to pretty-print with your chosen indentation (2 spaces, 4 spaces, or a tab).
  • Click Minify to collapse the JSON to a single line — useful before embedding it in a POST body or an environment variable.
  • Copy the output to your clipboard with one click, then paste it wherever you need it.
  • Hit Try an example to see a realistic sample JSON object if you want to demo the tool before using your own data.

Reading Syntax Errors

When your JSON contains a mistake, the tool displays the raw parser error message and — when the browser's JSON engine reports it — the exact line number and column. The most frequent causes of invalid JSON are trailing commas (JSON does not allow a comma after the last key–value pair or array element, unlike JavaScript objects and arrays), single-quoted strings (JSON mandates double quotes), and unquoted keys (property names must always be double-quoted strings in JSON, not bare identifiers).

Common Use Cases

This formatter is useful across a wide range of development and data tasks:

  • Inspecting an API response pasted from a browser DevTools network tab.
  • Cleaning up a machine-generated JSON configuration before committing it to source control.
  • Minifying a large JSON fixture or seed file to reduce bundle or payload size.
  • Verifying that a package.json or tsconfig.json you hand-edited is still valid after your changes.
  • Quickly checking the structure of a webhook payload without spinning up a dedicated tool.

Privacy

Every operation in this tool runs entirely inside your browser using the native JSON.parse and JSON.stringify functions built into every modern JavaScript engine. Your data never leaves your device — no upload, no server, no logs. That makes it safe to use with API keys, personal data, internal configuration, or any other sensitive JSON you might encounter during development.

Frequently Asked Questions

What is the difference between formatting and minifying JSON?

Formatting (also called pretty-printing) adds indentation and line breaks so the JSON is easy to read. Minifying does the opposite — it strips all unnecessary whitespace to produce the smallest possible representation, which is ideal for network payloads and stored data where human readability is not needed. Both operations produce exactly the same data; only the presentation changes.

How do I find and fix a JSON syntax error?

The most common JSON mistakes are trailing commas (e.g. the last item in an array or object cannot have a comma), single-quoted strings (JSON requires double quotes), and unescaped special characters inside strings. When you paste invalid JSON into this formatter it shows you the error message and, where possible, the exact line and column number so you can jump straight to the problem.

Does this tool work with large JSON files?

Yes. Because all processing runs entirely in your browser — no upload step required — there is no server-side file size limit. In practice, performance is limited by your device's memory and JavaScript engine, but the tool handles typical API payloads and configuration files (up to several megabytes) without trouble.

Which indentation style should I choose?

Two spaces is the most common convention in JavaScript, TypeScript, and JSON configuration files. Four spaces is traditional in Python and some enterprise codebases. Tab indentation lets each reader's editor render the depth they prefer and is favoured by some accessibility and style guides. All three options produce equally valid JSON.

Is undefined a valid JSON value?

No. JSON is based on a subset of JavaScript, but it does not include undefined, NaN, Infinity, or function values. The only primitive types allowed in JSON are strings (double-quoted), numbers, booleans (true/false), and null. If you paste JSON that contains undefined or other non-standard tokens, the validator will flag it as a syntax error.

Related tools