JSON Validator and Beautifier

Validate, beautify and format JSON online for free. Instantly spot syntax errors, indent or minify your JSON and copy it with one click.

1,086 views · 8 uses

./json-validator

Input

Formatted JSON

Paste your JSON and press "Validate & Beautify JSON" to see the result

Compartir

What this tool does

You paste JSON, press the button, and get one of two things: the document reformatted with the indentation you choose, or the exact syntax error stopping it from being parsed. Everything happens in your browser — no file upload, no server calls — so you can paste an API response containing tokens or customer data without it leaving your machine.

It is the operation you perform dozens of times a day working with APIs: a minified response arrives as a single 4,000-character line and you need to read it before deciding what to do with it.

How to use it

  1. Paste the JSON into the input field. Minified or already formatted both work.
  2. Choose the indentation: 2 spaces, 4 spaces, or tab.
  3. Press Validate and Beautify JSON.
  4. Copy the result with one click.

If the document is valid, the output panel shows the indented version. If it is not, it shows the parser’s message with the position of the character that breaks parsing.

The JSON errors that come up again and again

JSON is a deliberately small format. Most errors come from assuming it accepts things that JavaScript accepts.

Trailing comma

{
  "name": "Marco",
  "role": "developer",
}

That comma after the last value is valid in a JavaScript object literal and in Python, but not in JSON. It is by far the most frequent error.

Single quotes

{ 'name': 'Marco' }

The specification requires double quotes, both for keys and for string values. Single quotes are not JSON.

Unquoted keys

{ name: "Marco" }

In JavaScript the key can go bare. In JSON it is always quoted.

Comments

{
  // the user's identifier
  "id": 42
}

JSON has no comments. Neither // nor /* */. If you need to annotate a configuration file, either use a format that does allow them — YAML, JSON5, TOML — or put the note in one more key.

NaN, Infinity and undefined

They do not exist in JSON. Numbers must be finite, and absence of value is represented by null. If you serialize from JavaScript, JSON.stringify turns undefined into nothing inside an object and into null inside an array — an asymmetry that causes surprises.

Copying from the browser console

When you expand an object in DevTools and hit Copy object, what gets copied is usually JavaScript notation, with unquoted keys and sometimes truncated circular references. To get real JSON, use copy(JSON.stringify(obj)) in the console.

Beautify or minify: when to use which

They are the same operation in opposite directions, and the choice depends on who is going to read the result.

Beautify when a person is going to read the JSON: debugging an API response, reviewing a package.json, comparing two payloads in a diff. Indentation is what makes the nesting structure visible.

Minify when a machine is going to read it: HTTP request bodies, values stored inside a database, files served to the client. Stripping whitespace cuts the weight without changing the content, and on large responses the saving is real.

One detail that saves arguments in code review: JSON files versioned in Git are best stored formatted and with keys in a stable order. A diff over a single 4,000-character line is unreadable; over an indented document, you can see exactly what changed.

JSON in three rules

If you had to remember only three things about the format:

  • There are six types: string, number, boolean, null, array and object. There are no dates, no integers versus decimals, no comments. Dates travel as strings, almost always in ISO 8601.
  • Keys are strings and go in double quotes, always.
  • The top level can be any value. An array at the root is valid JSON, and so is a bare 42 or "hello". The idea that a JSON document has to be an object is a myth inherited from older versions of the specification.

When you need to transform, not validate

If the problem is not whether the document parses but what to do with it next, there is a specific tool for each case: convert it to CSV or YAML, generate TypeScript types from a sample, or compare two versions to see what actually changed between them — which is a structural comparison, not a text one, so reordered keys do not show up as differences.

Frequently asked questions

Is my JSON sent to a server?

No. Validation and formatting happen entirely in your browser using JavaScript's native JSON engine. What you paste never leaves your machine, so it is safe to use with API responses containing sensitive data.

What is the difference between validating and beautifying JSON?

Validating checks that the text follows the JSON grammar and points at the failure if it does not. Beautifying (or formatting) rewrites already-valid JSON with line breaks and indentation so a human can read it. This tool does both at once: valid JSON comes back formatted, invalid JSON comes back with the offending character.

Why is my JSON invalid when it looks fine?

The usual causes are a trailing comma before a closing bracket, single instead of double quotes, unquoted keys, or comments. JSON allows none of those even though JavaScript does. Another common one is copying the object straight out of the browser console, which prints JavaScript notation rather than JSON.

Can it handle large JSON files?

Yes, within your browser's memory. Running locally means no upload cap and no request limits. Multi-megabyte documents may take a moment to format, since the whole tree is built in memory.

Which indentation should I use?

Two spaces is the default convention across the JavaScript ecosystem and what Prettier and npm use. Four shows up in Java and .NET projects. For files going into a repository, what matters is that the team agrees; for JSON travelling over the wire, minify it and format only when you need to read it.

Reviews & ratings

No reviews yet. Be the first to leave one!

Write a review

Your rating *