JSON Formatter: Beautify, Validate and Minify JSON

Paste JSON into the box. It is checked as you type, laid out neatly or squeezed onto one line, and any mistake is pinned to its line and column.

TechFreeNo sign-upWorks on phones
Output style
––

–Top-level type
–Lines out
–Nesting depth
–Characters out
Objects and arrays–
Values–
Size–
Repeated names–
Error position–
Text at the error–

This tool runs in your browser. Nothing you type is uploaded or saved, and there is nothing to install or sign up for.

What this JSON formatter does with your data

JSON is the plain-text format that apps, APIs and config files use to pass data around. It is easy for a program to read and surprisingly easy for a person to break: one missing quote or one comma too many and the whole file is rejected. This tool reads your JSON strictly, tells you whether it is valid, and rewrites it in the layout you choose.

You can spread the data over indented lines so its structure is visible, or pack it into a single line with no spare spaces. If something is wrong, you get the line, the column and a plain sentence about what was expected at that spot. Everything runs inside your browser, so the text you paste is not sent anywhere.

How to format, check or shrink JSON

  1. Paste or type your data into Your JSON. The result updates with every keystroke.
  2. Under Output style, pick Pretty for an indented layout or Minify for one compact line.
  3. For the pretty layout, choose 2 spaces, 4 spaces or a tab in Indent for the pretty style.
  4. Tick Sort object names A-Z at every level if you want the members of every object in alphabetical order.
  5. Read the verdict in the navy panel, then press Copy result to take the output with you. Reset brings back the sample.

A worked example with the sample data

The page opens with a small student record of 120 characters on one line. It starts like this:

{"student":"Maya","grade":7,"subjects":["math","science"], ...}

With Pretty and 2 spaces the tool reports Valid JSON and lays the record out on 14 lines and 173 characters. The tiles show a top-level type of Object and a nesting depth of 2, because the subjects array and the locker object each sit one level inside the outer object. The detail rows count 2 objects with 8 names, 1 array, 4 strings, 2 numbers, 1 boolean and 1 null.

Switch the indent to 4 spaces and the same 14 lines grow to 205 characters. Choose Minify and you are back to the original 120 characters, since the sample had no spare spaces to begin with. Tick the sort box and the names come out as grade, locker, notes, passed, student, subjects.

The rules the checker applies

The parser follows the JSON grammar published by the IETF as RFC 8259 (read December 2026). In short:

  • A JSON text is one value: an object, an array, a string, a number, or one of the literal names true, false and null, which must be lowercase.
  • Object names are strings, a colon follows each name, and a single comma separates one member or element from the next. That leaves no room for a comma after the last item.
  • Strings are wrapped in double quotes. A double quote, a backslash or a control character inside a string has to be written as an escape.
  • Numbers are written in base 10, may start with a minus sign, and may not carry extra leading zeros.
  • Spaces, tabs and line breaks around brackets, colons and commas carry no meaning, which is exactly why reformatting is safe.

The grammar has no syntax for comments, so a line starting with two slashes is reported as an error here even though some config readers tolerate it.

Typical error messages and their fixes

You typedWhat the tool reportsFix
{"a":1,}Line 1, column 8: a trailing comma before the closing braceDelete the last comma
{a:1}Line 1, column 2: the name has no quotesWrite "a"
{'a':1}Line 1, column 2: single quotesUse double quotes
[01]Line 1, column 2: an extra zero at the start of a numberWrite 1
TrueLine 1, column 1: must be lowercaseWrite true

Only the first problem is reported. Fix it and the next one, if there is one, shows up straight away.

What stays untouched when the layout changes

Formatting only moves white space that sits between tokens. Every string and every number is carried over character for character. A long ID such as 12345678901234567890123 is not rounded, 1.50 keeps its trailing zero, and an escape like \u00e9 is not turned into the letter it stands for. Many formatters built on a programming language’s number type quietly change such values; this one does not parse numbers into numbers at all.

Sorting is the one option that changes more than spacing. It reorders the members of each object by name, capitals before lowercase, and leaves arrays alone because the order of an array is part of the data.

Repeated names

RFC 8259 says the names inside an object should be unique and warns that software behaves unpredictably when they are not. The tool therefore keeps every copy and lists the repeated names with their line numbers in the Repeated names row, so you can decide which one is meant.

Limits and common slip-ups

  • The input limit is 100,000 characters, and nesting deeper than 200 levels is refused.
  • Text copied from a word processor often contains curly quotes or a non-breaking space. Both look right and both are invalid; the error message names the invisible character by its code.
  • JavaScript object literals, Python dictionaries and JSON look alike but are not the same. Python’s None, a not-a-number value and unquoted names all fail.
  • The tool checks syntax only. It cannot tell you whether a field your app needs is missing or has the wrong type.
  • Avoid pasting passwords or private keys into any web page as a habit, even one that works offline like this.

Handy ways to use it

Students in a first coding class can paste the response of a practice API and finally see which bracket closes which. Teachers can minify a sample file to show how much of a payload is only white space, or sort two versions of a file and run them through the text diff checker to spot the single value that changed.

If your data starts life as a spreadsheet export, the CSV to JSON converter builds the JSON for you. When JSON has to travel inside a link, pass the minified line through the URL encoder, and when it must sit inside an HTML attribute use the HTML entity encoder. Tokens that carry JSON in Base64 can be opened with the Base64 decoder first and formatted here afterwards.

More helpers for code and data are listed with the other tech and web tools, and the full set of free online tools covers school, math and text tasks too.

Frequently asked questions

How do I know if my JSON is valid?

Paste it into the box. If the panel says Valid JSON, it passed a strict check against the JSON grammar. If not, the message gives the line and column of the first problem and what was expected there.

What is the difference between pretty-printing and minifying JSON?

Pretty-printing puts each member on its own indented line so people can read it. Minifying removes every space and line break between tokens so the file is as small as possible. The data is identical either way: the 120-character sample becomes 173 characters with 2-space indents and 120 again when minified.

Why is a trailing comma an error in JSON?

In the JSON grammar a comma only separates one item from the next, so a comma must always be followed by another item. For the text a:1 followed by a comma and a closing brace the tool points at line 1, column 8, where the closing brace appears instead of a name.

Does sorting the names change my data?

It changes the order of the members inside each object and nothing else. Arrays keep their order and every value stays exactly as typed. Programs that read objects by name get the same result.

Will big numbers or decimals be rounded?

No. Numbers are copied through as text, so a 23-digit ID or a value like 1.50 comes out exactly as it went in.

Is my JSON uploaded anywhere?

No. The checking and formatting happen in your browser and the page makes no network request with your text.

Related tools

Browse all free tools →