Developer Tools

JSON Validator & Beautifier

Beautify, minify and validate JSON, with precise error locations, optional key sorting and adjustable indentation.

Free to use No registration Mobile friendly Unlimited usage

What is the JSON Validator & Beautifier?

JSON that comes back from an API is almost always minified - one long line with no spaces, because every byte saved is bandwidth saved. That is the right decision for a machine and a terrible one for a human trying to work out why a field is missing.

This tool does three related jobs: it expands minified JSON into something you can read, compresses it back down again, and tells you precisely where the syntax is broken when it will not parse.

Validation is the part that saves the most time

When JSON fails to parse, most environments give you an unhelpful message. Somewhere in 40,000 characters there is a missing comma, and you are told only that something went wrong.

This tool reports the line and column. That turns a hunt into a lookup. In practice the cause is nearly always one of five things: a trailing comma after the last item in an array or object, single quotes where JSON requires double, an unquoted key, a stray comment, or a control character inside a string that should have been escaped.

Two of those deserve a note, because they trip up experienced people. JSON does not allow comments - not //, not /* */, in any position. And JSON does not allow trailing commas, even though JavaScript itself does. A config file that works fine in your editor can be invalid JSON for exactly that reason.

Beautifying and the indent setting

Beautify rebuilds the document with line breaks and indentation. Two spaces is the common default and what most style guides specify. Four is easier to scan when structures nest deeply. Tabs are there for teams whose linter demands them.

The choice has no effect on meaning - whitespace outside strings is invisible to any JSON parser. Pick whichever makes the structure clearest to you.

Sorting keys

Sort keys alphabetises every object in the document, at every level of nesting. This has one specific purpose that makes it worth knowing about: comparing two JSON documents.

Objects have no inherent key order, so two API responses containing exactly the same data can serialise their keys differently. Diff them raw and you get dozens of false changes. Sort both first and the diff shows only the fields that genuinely differ. It is the fastest way to answer "what changed between these two responses?"

Minifying

Minify strips every unnecessary space and line break. For a configuration file you are embedding in a URL, a payload you are sending in a request, or a value going into an environment variable, this is what you want. The size counters show the before and after, which is usually a reduction of a third to a half depending on how deeply the document was nested.

Your data stays with you

Parsing happens in your browser using the same JSON engine the browser already uses for every website you visit. Nothing is transmitted. This matters more for JSON than for most formats, because API responses routinely contain access tokens, customer records and internal identifiers - exactly the sort of thing that should never be pasted into an unknown web service.

Benefits of using the JSON Validator & Beautifier

Errors with a location

Instead of a vague parse failure you get the line and column, turning a search through 40,000 characters into a single lookup.

Sort keys to compare responses

Alphabetising every object at every level lets you diff two API responses without dozens of false differences from key ordering.

Both directions

Expand minified JSON to read it, then compress it again for a URL, a request body or an environment variable.

Tokens never leave the page

API responses are full of credentials and customer data, and this parses them locally rather than uploading them.

How to use the tool

Step 1

Paste your JSON, minified or formatted, valid or not

Step 2

Choose beautify to expand it, minify to compress it, or validate to check it only

Step 3

Set the indent width, and turn on sort keys if you plan to compare two documents

Step 4

Press Format JSON - errors report the exact line and column

Popular use cases

  • Reading minified API responses
  • Debugging malformed payloads
  • Comparing two API responses
  • Preparing config files
  • Compressing JSON for URLs
  • Checking webhook bodies
  • Cleaning exported data files
  • Validating before deployment

Frequently asked questions

Five causes account for almost everything: a trailing comma after the final item, single quotes instead of double, an unquoted key, a comment, or an unescaped control character in a string. The last two surprise people most - JSON permits no comments at all, and unlike JavaScript it rejects trailing commas.

Files of a few megabytes are fine. Beyond roughly ten megabytes the browser may pause noticeably while parsing, because everything is held in memory at once. For files that large a command-line tool such as jq will be more comfortable.

Ready to start using TU Web Tools?

Free, browser based utilities for developers, SEO professionals, students and businesses.

Free to use  •  Mobile friendly  •  No installation required