Search

Jump to a tool or a page

JSON, formatted
and validated

Paste JSON below to format, beautify, or minify it instantly, and catch syntax errors before they cause problems. Free, no sign-up required.

JSON Formatter

Features

Everything you need to work with JSON, in one simple tool.

Instant Formatting

Format JSON of any size in milliseconds. No waiting, no loading spinners. Just immediate results.

Error Detection

Instantly identify syntax errors in your JSON. Clear error messages tell you exactly what went wrong and where.

Syntax Highlighting

Color-coded output makes it easy to read and understand your JSON structure at a glance.

One-Click Copy

Copy your formatted JSON to clipboard with a single click. Ready to paste wherever you need it.

How to Format JSON

Formatting JSON takes just a few seconds. Here's how.

1

Paste Your JSON

Copy your JSON from any source (API response, file, or code) and paste it into the input area above.

2

Click Format

Hit the Format button to prettify your JSON with proper indentation. Or use Minify to compress it.

3

Copy or Download

Copy the formatted result to your clipboard with one click, ready to use anywhere.

When to Use a JSON Formatter

Here are the most common scenarios where this tool saves you time.

Debugging API Responses

API returned a wall of minified JSON? Paste it here to see the structure clearly and identify issues faster.

Formatting Config Files

Make your package.json, tsconfig.json, or any configuration file readable and properly indented.

Validating JSON Data

Before sending JSON to an API or storing it in a database, validate that the syntax is correct.

Minifying for Production

Reduce file size by removing whitespace and formatting. Minified JSON loads faster in production.

Working with JSON

A short reference on the parts of the format that cause the most trouble in practice: what the grammar actually allows, why parser errors point where they do, and the precision limit that quietly corrupts large numbers.

What counts as valid JSON

JSON is a much smaller language than most people expect. The formal grammar fits on a single page, and it allows exactly six value types: object, array, string, number, boolean, and null. Anything outside that set is a syntax error, no matter how reasonable it looks in JavaScript.

This is the source of most confusion. JSON looks like JavaScript object literal syntax, so developers reach for JavaScript habits that the parser will reject. Knowing the boundary saves a lot of debugging.

  • Keys must be double-quoted strings{name: "ada"} and {'name': 'ada'} are both invalid. Only {"name": "ada"} parses.
  • No trailing commasA comma after the last element of an object or array is a syntax error, even though modern JavaScript allows it.
  • No commentsNeither // nor /* */ is permitted. Configuration formats that allow comments, such as JSONC or JSON5, are separate languages.
  • No undefined, NaN, or InfinityThese are JavaScript values with no JSON equivalent. JSON.stringify silently drops undefined in objects and converts NaN and Infinity to null.
  • Strings use double quotes onlySingle-quoted strings are invalid, and literal newlines inside a string must be escaped as \n.

Reading parser error messages

Error messages point at the position where parsing became impossible, which is often slightly after the actual mistake. A missing closing brace is usually reported at the end of the document, not where the brace should have been.

A few messages come up constantly and have specific causes worth recognising:

  • Unexpected token < in JSON at position 0You are parsing HTML, not JSON. This almost always means an API returned an error page or a login redirect instead of data.
  • Unexpected end of JSON inputThe document is truncated. Common causes are a response cut short, a partially written file, or a string that was never closed.
  • Unexpected token } in JSONUsually a trailing comma just before the brace, or a missing value after a key.
  • Unexpected non-whitespace character after JSONThe document contains two values concatenated together. Newline-delimited JSON, where each line is its own document, needs to be parsed line by line.

An invisible byte order mark at the start of a UTF-8 file causes a position 0 error too, which is particularly confusing because the file looks correct in every editor.

Numbers lose precision above 2^53

JSON does not distinguish integers from floating point numbers, and JavaScript parses every number into a 64-bit float. Integers larger than 9,007,199,254,740,991 cannot be represented exactly, so they change value on the way through.

This matters in practice because large database identifiers, Twitter-style snowflake IDs, and financial values in the smallest currency unit all routinely exceed that limit.

// The value changes silently during parsing
JSON.parse('{"id": 9007199254740993}')
// → { id: 9007199254740992 }

The usual fix is to transmit large identifiers as strings. If you control the API, quoting the value costs nothing and removes an entire class of bug. Formatting the JSON will not corrupt these values, since this tool preserves the document as text.

When to minify and when not to

Minifying removes every byte of whitespace outside string literals. On a typical API payload that reclaims somewhere between 10 and 20 percent of the size, and on deeply nested documents with long indentation it can be considerably more.

That saving is worth having on the wire, but it is worth less than you might think once transport compression is involved. Gzip and Brotli both compress repeated indentation extremely well, so the gap between a formatted and a minified document narrows sharply after compression.

Minify what ships to users. Keep files that humans edit, such as configuration checked into a repository, formatted with stable indentation so that version control diffs stay readable.

Duplicate keys and key order

The specification does not forbid duplicate keys, and it does not define what a parser should do with them. In practice most implementations, including JavaScript, keep the last occurrence and discard the earlier ones. Others keep the first, and some reject the document outright.

Key order is similarly unspecified. Objects are defined as unordered collections, so nothing guarantees that the order you wrote is the order you get back. Most parsers do preserve insertion order in practice, but code that depends on it is relying on an implementation detail rather than the format.

If ordering carries meaning in your data, use an array. Arrays are ordered by definition, and the intent is then explicit to anyone reading the document.

Never parse JSON with eval

Older code sometimes evaluates JSON as JavaScript, which works because JSON is close to a subset of the language. It is also a straightforward remote code execution vulnerability: anything the attacker puts in the response runs with your page privileges.

JSON.parse has been available in every browser and runtime worth targeting for well over a decade. There is no remaining reason to use anything else. If you need to reject malformed input gracefully, wrap the call in try/catch rather than pre-validating with a regular expression.

Common questions

What is JSON and why format it?

JSON (JavaScript Object Notation) is a lightweight data format used to store and exchange data. Formatting JSON adds proper indentation and line breaks, making it much easier to read and understand the data structure. This is especially helpful when debugging or reviewing API responses.

What is the difference between prettify and minify?

Prettify adds indentation and line breaks to make JSON human-readable. Minify removes all unnecessary whitespace to reduce file size, which is useful for production environments where smaller file sizes mean faster loading.

How do I know if my JSON is valid?

When you paste JSON into our formatter, it automatically validates the syntax. If there are errors, you will see a clear error message indicating what is wrong and where the issue is located.

Is there a size limit for JSON formatting?

Our formatter handles JSON files of practically any size. While extremely large files (over 10MB) may take a moment to process, most JSON data will format instantly.

Can I use this tool for free?

Yes, this JSON formatter is completely free to use. There are no usage limits, no premium features, and no sign-up required. Use it as much as you need.

Related tools

Other free tools that tend to come up in the same work.