JSON Formatter

JSON Formatter

Paste JSON to pretty-print it, minify it or sort its keys. If it isn’t valid, you see the line and column of the first error, the spot marked in your text and how to fix it. Your JSON never leaves the browser.

Output
Indent
  • Formatted JSON

    { "order": { "id": 12345678901234567890, "status": "shipped", "items": [ { "sku": "BK-101", "qty": 2, "price": 12.50 }, { "sku": "MUG-7", "qty": 1, "price": 9.99 } ], "customer": { "name": "Ana López", "newsletter": false }, "note": null } }

ResultValid JSON
Keys14
Nesting depth4
Size before (bytes)206
Size after (bytes)358
Change in size73.79%
Lines23
Objects5
Arrays1

Numbers and strings are copied exactly as written — nothing is rounded or re-escaped.

Calculated on your device · formulas checked against known results · How we test

How to use the JSON formatter

  1. Paste your JSON — an API response, a configuration file, a log entry — into the box. It is checked and formatted as you paste.
  2. Choose Format for readable JSON indented with 2 spaces, 4 spaces or tabs, or Minify to remove every space and line break between values.
  3. Tick Sort keys to put the properties of every object in alphabetical order, which makes two versions of the same data easy to compare. Arrays keep their order.
  4. Press Copy beside the result. If the JSON is invalid, you get the problem, its line and column, and the line itself with a ^ under the spot.

What formatting, minifying and validating do

Formatting — also called beautifying or pretty-printing — puts each property and list item on its own line and indents it by how deeply it is nested. Minifying does the opposite and leaves the most compact form. Neither changes the data. Validation checks the text against the JSON standard (RFC 8259, the same grammar as ECMA-404), whose rules every JSON parser enforces: names and strings in double quotes, no trailing commas, no comments, lowercase true, false and null, and numbers without leading zeros, NaN or Infinity. It reports the first error it finds.

Many online formatters run your text through JavaScript’s JSON.parse and print it again. This one reads the text itself and keeps every value exactly as written:

Common JSON errors and how to fix them

ErrorInvalidValid
Trailing comma{"a": 1, "b": 2,}{"a": 1, "b": 2}
Single quotes{'name': 'Ana'}{"name": "Ana"}
Property name without quotes{name: "Ana"}{"name": "Ana"}
Comment{"port": 80 // web}{"port": 80}
Missing comma[1 2 3][1, 2, 3]
Curly quotes from a word processor or chat{“a”: 1}{"a": 1}
Python or JavaScript values{"x": None, "y": True, "z": undefined}{"x": null, "y": true, "z": null}
Leading zero{"zip": 02134}{"zip": "02134"}
Single backslash{"path": "C:\Users"}{"path": "C:\\Users"}
Several values one after another{"a": 1} {"b": 2}[{"a": 1}, {"b": 2}]

When a closing bracket is missing, the parser only notices at the very end, so “Unexpected end of JSON” points at the last line even though the missing } or ] belongs further up. Formatting the part that is valid and looking at where the indentation stops making sense is the fastest way to find it.

Worked example: how much indentation adds

The sample in the box is a 206-byte, one-line API response with 14 keys nested 4 levels deep. Formatted, it grows to 23 lines:

OutputSize
Minified206 bytes
Tabs300 bytes
2 spaces358 bytes
4 spaces474 bytes

Tabs keep formatted JSON smallest because each level costs one byte. For files that people read and edit, the readability is usually worth the extra bytes; minify JSON you send or store in bulk.

Limits and tips

Your JSON stays on your device

Formatting and validation run in your browser. JSON often holds API keys, tokens or customer records, and none of it is uploaded or logged. It is not saved either: reloading the page clears it.

Frequently asked questions

Is my JSON sent to a server?

No. The page formats and validates it with JavaScript in your browser, so it works with private data and even offline once the page has loaded.

Why is my JSON invalid when it works in JavaScript?

JavaScript object literals allow things JSON does not: unquoted property names, single quotes, trailing commas, comments, undefined and functions. JSON is a stricter data format so that every language can read it the same way.

What does “Unexpected end of JSON” mean?

The text ended while something was still open — usually a missing } or ], or a string without its closing quote. It can also mean the text was cut off when it was copied.

Does sorting the keys change my data?

No. RFC 8259 defines an object as an unordered collection of name/value pairs, so the order of keys carries no meaning. Arrays are ordered, so their items are never sorted.

What is the difference between a JSON formatter, beautifier and validator?

They are names for the same job: a formatter or beautifier makes JSON readable, and a validator checks it against the standard. This page does both at once — invalid JSON is never formatted, so a formatted result is also valid.

Embed this calculator on your website

Free for any website or blog. Paste this code where you want the calculator to appear:

All free calculator widgets

Last updated: October 15, 2026

Menu

Categories

Finance Calculators29 calculatorsBusiness & Shopping Calculators8 calculatorsHealth & Fitness Calculators11 calculatorsMath & School Calculators22 calculatorsDate & Time Calculators16 calculatorsHoliday Countdowns17 calculatorsEveryday Tools30 calculatorsMic, Camera & Sound Tools6 calculatorsImage & PDF Tools7 calculators

CalcWorthy

AboutContactPrivacy PolicyTerms of Use

Language

Language
EnglishEnglishالعربيةArabicবাংলাBanglaDeutschGermanEspañolSpanishفارسیPersianFrançaisFrenchעבריתHebrewहिन्दीHindiBahasa IndonesiaIndonesianItalianoItalian日本語Japanese한국어KoreanBahasa MelayuMalayNederlandsDutchPolskiPolishPortuguêsPortugueseРусскийRussianไทยThaiTürkçeTurkishУкраїнськаUkrainianاردوUrduTiếng ViệtVietnamese简体中文Simplified Chinese