🔒 100% private — runs in your browser, nothing is uploaded

JSON Formatter & Validator

Format, minify and validate JSON in one click.

JSON is the lingua franca of APIs — but a missing comma or quote breaks everything.

Related tools: Regex Checker

Read the guide: How to Format, Validate and Fix Broken JSON · JSON Without Tears: Structure, and the Five Errors Everyone Makes

Quick answers

Does formatting JSON change my data?

If you format or minify here, no. The tool walks your original text and only adds or removes whitespace outside strings, so values, key order, and number spellings stay exactly as you typed them. A 1.50 stays 1.50, and 1e3 stays 1e3. Nothing gets sorted, rounded, or rewritten behind your back during formatting.

That preservation cuts both ways. Because the formatter never rebuilds your data, it won't clean it up either. Duplicate keys stay duplicated, odd number formats stay odd, and keys stay in whatever order you typed them. If you want sorted keys or normalised numbers, you need a tool that parses and re-serialises — and check its output closely when you use one.

Can JSON be valid and still break my app?

Yes, easily. Parsing only checks grammar — brackets match, strings are quoted, commas sit in the right places. It doesn't check that a field exists, that an age is a number instead of a string, or that a date makes sense. Your app can reject perfectly valid JSON because the shape isn't what it expected.

Think of it in two layers. This page checks layer one, the grammar. Your app lives at layer two, where field names, types, and ranges matter. If valid JSON still fails, print the parsed object and compare it field by field with what the receiving code expects. Look for quiet mismatches — a string where a number should be is the classic.

Can this tool fix broken JSON for me?

No. This tool reports the error JSON.parse gives it, with a position when the browser supplies one, and that points you close to the trouble. It doesn't guess what you meant or patch the text for you. A missing comma, a stray trailing comma, or an unquoted word is yours to fix, then paste back and check again.

Use the position as a starting point, not a verdict. Work backwards from it and check the usual suspects first: the comma before the spot it names, a quote that never closed, a bracket opened earlier and forgotten. Fix one thing at a time and re-check after each edit. Small steps stop you trading one error for another.

How to use

  1. Paste your JSON into the box.
  2. Click Format for readable output or Minify for compact output.
  3. Errors are explained in plain language.

About this tool

This formatter pretty-prints nested data, minifies payloads for production, and pinpoints syntax errors.

Your data never leaves your browser — safe for API keys and private payloads.

How it works

JSON (JavaScript Object Notation, RFC 8259) has only six value types: objects ({"key": value}), arrays ([1, 2]), strings (always double-quoted), numbers, true/false, and null. There are no comments, no trailing commas, and no single-quoted strings — those three account for most validation failures.

Formatting (pretty-printing) adds indentation and line breaks without changing meaning; minifying strips all unnecessary whitespace to shrink payloads. {"a":1} and its four-space-indented version are identical to every parser.

Validating before you send catches syntax errors locally. A missing comma surfaces here as a clear message instead of a cryptic 400 response from the server.

Formatting and minifying don't go through the parsed value at all. A small scanner walks your raw text one character at a time and keeps one key fact in mind: are we inside a string right now, or outside it? A quote toggles that state, unless the quote is escaped with a backslash — then the scanner treats it as part of the string and keeps going. Whitespace outside strings is fair game. The minifier drops it, and the formatter replaces it with new lines and two-space indents based on nesting depth. Whitespace, commas, and colons inside a string are data, so they're left untouched.

That raw-text approach is why your numbers and key order survive. If the tool parsed your JSON and printed the value back out, 1.50 could come back as 1.5, 1e3 could turn into 1000, and very long numbers could lose precision. Key order could shift, too. By working on the text you typed instead of a rebuilt value, the formatter changes the spacing around your data and nothing else.

Validation takes the other path. It hands your text to the browser's built-in JSON.parse, and if that throws, the tool shows you the message it gave. That message usually names the kind of problem and a position, which helps you find a missing comma a line or two back. It doesn't highlight the exact character at fault or explain what you meant. Parser positions point at where the parser gave up — often just after the real mistake.

What this tool can’t do

Valid isn't the same as correct. This tool checks syntax only — whether brackets close, strings are quoted, and commas sit where they should. It has no schema to check against, so it can't tell you a required field is missing, a price came through as text, or a date is nonsense. JSON that sails through here can still be the wrong data for your app.

It won't fix broken JSON for you. If something fails, you get the browser parser's error message and, when it provides one, a position in the text. That's a clue, not a repair. It won't guess you meant a comma instead of a colon, or that a word was supposed to be quoted. You make the edit, paste it back, and check again.

Duplicate keys slip past without a warning. Paste an object with the key id in it twice and the formatter will keep both entries, in order, exactly as typed. But when another program parses that same text with JSON.parse, it keeps only the last value and quietly drops the first. So the formatted output can look fuller than the data your code actually ends up using.

Plain JSON only. Comments, trailing commas, single-quoted strings, and unquoted keys all fail here, even though some tools and config formats accept them. Those are JSON5 or JSONC habits, and the strict JSON parser underneath this page won't bend for them. Strip them out first, or expect an error.

Size has a ceiling, and it's your browser's, not a neat number on a chart. Everything happens in the page, in a textarea, with your text held in memory. A few hundred kilobytes is fine. A multi-megabyte dump can get sluggish or freeze the tab. For files that big, a command-line parser on your own machine will cope better.

Worked examples

Debugging an API call: Paste the body you are about to POST. If the validator reports an unexpected token near position 42, you know exactly where the missing comma is instead of guessing from the server's error.

Reading a minified response: APIs usually return one long line. Paste {"users":[{"id":1,"name":"Ada"}]} and format it to browse the structure comfortably.

Shrinking a small profile object, step by step: Start with this object, typed with spaces so you can read it: {"name": "Ada", "role": "editor", "tags": ["math", "code"], "active": true}. First, run Format. You get the same data spread over 9 lines with two-space indents — 97 characters in total, counting the line breaks. Nothing has moved and no value has changed. It's just easier to scan. Next, copy that formatted version and run Minify. The scanner strips every space and line break outside a string, and you get {"name":"Ada","role":"editor","tags":["math","code"],"active":true} — exactly 67 characters on one line. Last, do the maths: 97 minus 67 is 30 characters saved, and 30 out of 97 is about 31%. Format for your eyes while you're debugging, minify for the wire when size counts, and expect roughly that saving on small, flat objects like this one.

Quick reference

Error messageUsual causeFix
Unexpected token \u0027Single-quoted stringsUse double quotes
Unexpected token }Trailing comma like {"a": 1,}Remove the last comma
Unexpected token nUnquoted key like {name: "x"}Quote every key
Unexpected token /// comments in the textJSON has no comments — delete them

Frequently asked questions

What makes JSON invalid?

Usually trailing commas, single quotes, comments, or unquoted keys — all common when copying from JavaScript.

What is the difference between format and minify?

Format adds indentation for humans; minify strips all whitespace for the smallest size.

Is my JSON uploaded?

No. Parsing happens entirely in your browser.

Will this tool sort my keys alphabetically?

No, and that's deliberate. Your keys stay in the exact order you typed them, top to bottom. Sorting sounds tidy, but it can hide meaning — some payloads care about order, and even when they don't, reordering makes diffs harder to read. If you need alphabetical keys, sort them in your editor before you paste the text in here.

Can I paste JSON that has comments or trailing commas in it?

Not as-is. It'll fail validation, because the parser here follows strict JSON, and strict JSON has no comments and no trailing commas. Plenty of config files allow both, which is why pasted config often errors here. Remove the comments and the last comma in each list or object, then try again — the rest of your data usually needs no changes at all.

Is there a size limit for the JSON I paste?

There's no fixed number built into the tool. The practical limit is your device and browser, because your text lives in the page's memory and gets handled in a textarea. Small and medium payloads — the kind you copy out of an API response — are fine. If a paste feels slow or the tab stutters, split the file up or switch to a local command-line tool.

📦 Embed this tool on your site

<iframe src="https://verystep.com/embed/json/" title="JSON Formatter & Validator" width="100%" height="520" loading="lazy" style="border:0"></iframe>

Free to use. The embed shows a small "Powered by Verystep" link.

First time embedding? Read the step-by-step guide →

More free tools