JSON Formatter

Free online JSON formatter and validator. Beautify, minify and check JSON with clear error messages that show the line and column of the problem.

✓ Runs in your browser, nothing is uploaded
Waiting for input

How to use the JSON formatter

  1. Paste your JSON into the input box. It is checked as you type.
  2. Press Format to make it readable, or Minify to shrink it to a single line.
  3. Choose the indentation you prefer, and tick Sort keys to put object keys in alphabetical order.
  4. Copy the result or download it as a .json file.

If your JSON is not valid, the message under the editor says what is wrong and where, with the line and column when your browser provides them. Common causes are a trailing comma, single quotes around text, or a missing closing bracket.

JSON Formatter: a complete guide

What JSON is and why it is everywhere

JSON stands for JavaScript Object Notation. It is a plain text format for storing and exchanging structured data, and it is the most common way for web services to send information to apps and websites. When an app shows the weather, a shopping cart or a list of messages, the data very often arrives as JSON. It also appears in configuration files, logs, database exports and browser storage.

The format is built from just a few pieces: objects written in curly braces with named keys, arrays written in square brackets, and values that are text, numbers, true, false or null. Because it is so small, nearly every programming language can read and write it.

Formatting, minifying and validating

Data coming from a server is often a single long line with no spaces, which is efficient for machines but almost impossible for a person to read. The formatter adds line breaks and indentation so you can see how the data is nested. Minifying does the opposite and removes every unnecessary space and line break, which makes the file as small as possible for sending or storing.

Validating means checking that the text follows the JSON rules. This tool does it as you type, so you find a problem at the moment you create it instead of when an application fails later.

The rules JSON is strict about

Most invalid JSON breaks one of a handful of rules. Knowing them saves a lot of time.

  • Keys and text values must use double quotes. Single quotes are not allowed.
  • There must be no trailing comma after the last item in an object or an array.
  • Keys must always be in quotes, unlike in a JavaScript object where they can be bare.
  • Comments are not part of JSON, so lines starting with // or blocks in /* */ cause an error.
  • Values can only be text, numbers, true, false, null, objects and arrays. Things like undefined, NaN and dates written as code are not valid.
  • Every opening bracket or brace needs its matching closing one.

How to fix an error

When the JSON is not valid, the message under the editor describes the problem and, when your browser provides it, the line and column where parsing stopped. The position is where the parser noticed something was wrong, which is sometimes just after the real mistake. If the message points at a closing bracket, look at the line before it for a missing comma or an extra one. If it points at the end of the text, a bracket or a quote was probably left open.

A reliable approach is to fix the first error shown and check again. A single mistake early in the text can cause several error messages further down, and they often disappear together.

Sorting keys and choosing indentation

Sorting keys alphabetically makes two versions of the same data easier to compare, because the keys always appear in the same order. It is useful before you commit a configuration file or look for differences between two API responses. Indentation of two spaces keeps files compact, while four spaces is easier to read for deeply nested data. Pick whichever matches your team or project style.

Limits worth knowing about

JSON itself does not set a limit on number size, but browsers read numbers as standard floating point values. Integers larger than 9,007,199,254,740,991 can be rounded when they are read. If you handle long identifiers or exact money values, store them as text instead of numbers. Also note that the order of keys inside an object has no meaning in the standard, so do not rely on it unless you control both ends.

Keep sensitive data in mind

Developers often paste real API responses into online formatters, and those can contain tokens, emails and personal records. This formatter runs in your browser and does not send what you paste to a server, but it is still good practice to remove secrets before sharing JSON in tickets, chats or public forums.

Related guides

Frequently asked questions

What makes JSON invalid?

The most common problems are single quotes instead of double quotes, trailing commas, unquoted keys, comments, and missing brackets or braces.

What is the difference between formatting and minifying?

Formatting adds indentation and line breaks so people can read the data. Minifying removes all extra whitespace to make the file as small as possible.

Can very large numbers lose precision?

Yes. Browsers read JSON numbers as standard floating point values, so integers larger than 9,007,199,254,740,991 can be rounded. Keep such values as strings if exact digits matter.

Is my JSON sent to a server?

No. Formatting and validation run in your browser, so your data stays on your device.

More tools you may like