JSON Formatter: How to Format, Validate and Fix Messy JSON

JSON is the plain-text format that websites, apps and APIs use to swap structured data — and sooner or later, every blogger ends up staring at a wall of it. A JSON formatter takes that wall — cramped, minified or slightly broken — checks its syntax, and lays it out with neat indentation so a human can actually read it. Our free json formatter does the whole job in your browser: format, minify and validate, with the exact line and column of any error pointed out to you. Nothing is uploaded anywhere; the text never leaves your device.
You don’t need to be a developer to meet JSON. It turns up in WordPress REST API responses when a plugin or companion app pulls your posts, in the JSON-LD schema markup you paste into pages for rich results, in plugin settings and config files, in analytics exports, and in the migration files you handle when moving hosts or rebuilding a site. Most of the time it arrives minified — one endless line — which is perfectly fine for machines and fairly miserable for people.
What JSON Is, in Plain Words
JSON stands for JavaScript Object Notation, which sounds forbidding and isn’t. It’s data written as labelled values: an object in curly braces { } holds pairs like "title": "My First Post", a list goes in square brackets [ ], text strings wear double quotes, and numbers, true/false and null cover the rest. A complete, tiny example looks like this:
{
"title": "My First Post",
"published": true,
"tags": ["blogging", "seo"]
}Read it as a set of labelled boxes and it stops being scary. The catch is that machines parse JSON strictly — there’s no “close enough”. One missing comma or one stray bracket and the whole file fails, usually with a terse error and no clue about which of your four hundred lines caused it. That gap between “easy for machines” and “opaque for humans” is exactly what a formatter bridges.
The flavour of JSON bloggers paste most often is JSON-LD — the schema markup that tells Google “this page is an Article, these are its FAQs”. If you build yours with a generator, our schema generator guide walks through creating Article, FAQ and HowTo markup step by step. Whichever route you take, run the finished block through a formatter before it goes live: a single syntax slip can make search engines quietly ignore the whole snippet.

What Formatting and Validating Actually Do
Formatting (often called beautifying or pretty-printing) means parsing the JSON and printing it back out with consistent indentation — two spaces, four spaces or a tab per level — so each nested layer steps visibly inward. Structure you couldn’t see in a one-line blob becomes obvious: what’s inside what, where a list starts and ends, whether that block belongs to the post or the author.
Validating is the strict parse itself. Every bracket must have its partner, every pair of items needs a comma between them (and no comma after the last one), every string must be double-quoted and properly escaped. If anything breaks the rules, there is no output — you get an error instead.
Here’s the limit worth understanding, because it keeps you out of trouble. Validation checks syntax — the grammar — not meaning. A formatter will happily approve JSON whose prices are wrong, whose dates are in the past, or whose "published" flag says false when you meant true. And it doesn’t repair anything for you: it points at the error, shows you the line, and leaves the fixing to you. That’s a feature, not a gap. A tool that silently “fixed” your file would be changing your data in ways you never chose.
Minified vs Pretty JSON: Which One Do You Need?
They’re the same data in two outfits, and you’ll want both at different moments.
Minified JSON has every spare space and line break stripped out, leaving one dense line. It’s the smallest possible file, which is why APIs send it and why it’s a sensible form to paste into a page as schema markup — fewer bytes for visitors to download. Pretty JSON is the indented version: one item per line, nesting visible, made for human eyes. It’s what you want for reading an API response, editing a config file, comparing two exports, or hunting a bug.
The practical rule: pretty for working on it, minified for shipping it. Our tool converts in both directions, so you never have to choose a side permanently.

How to Use the JSON Formatter
Open the json formatter and you’ll see two panels — your input on the left, the formatted, colour-highlighted output on the right — with the action buttons along the top. Everything runs locally in the page.
- Paste your JSON into the left panel. A byte count under the panel shows the size of what you’ve pasted.
- Pick your indent — 2 spaces (the default), 4 spaces, or Tab. It only affects how pretty output is spaced.
- Choose an action. Format / Beautify for the indented version, Minify for the one-line version, or Validate only if all you need is a verdict.
- Read the result. Valid JSON appears colour-highlighted in the output panel — keys, strings, numbers, booleans and null each in their own colour — with a green “Valid JSON” confirmation. Invalid JSON brings up a red error panel instead (more on reading it below).
- Check the statistics. Tiles under the panels show bytes in and out, the maximum nesting depth, and counts of keys, objects, arrays, strings and numbers — a quick way to sanity-check that an export contains roughly what you expected.
- Take it away. Copy output puts the result on your clipboard; Download .json saves it as a file (named formatted.json).
New to all this? The Load sample button drops in a small, valid example you can format and minify to see the tool work, and Load broken sample loads a deliberately broken one — single quotes and trailing commas included — so you can watch the error reporting do its job before trusting it with your own files.
There’s a second, smaller tool further down the page: an escape / unescape box that turns plain text into a safely escaped JSON string, and back again. It’s what you need when embedding a sentence containing quotes or line breaks inside JSON by hand. For the neighbouring jobs — Base64 and URL encoding — our text encoder and decoder handles the converting in the same nothing-leaves-your-browser way.
How to Read a Validation Error (and Fix the Usual Suspects)
When your JSON fails, the error panel shows three things: the parser’s own message, the line and column where the problem sits (in every case where the browser reports a position), and the offending line itself with a caret ^ marking the column. The messages themselves can be terse — a bare “Unexpected token” doesn’t tell you much — so treat the location as the real information.
One subtlety saves a lot of head-scratching: a parser reports where it noticed the problem, which is often one token after the actual mistake. A missing comma at the end of line 4 usually gets flagged at the start of line 5, because that’s where the parser ran into something it couldn’t explain. So look at the flagged spot — and the line just before it. Then check against the usual suspects:
- Trailing comma — a comma after the last item in an object or array:
{"a": 1,}is invalid. Delete the spare comma. - Single quotes —
'text'fails; JSON strings must use double quotes:"text". - Unquoted keys —
{name: "x"}fails; every key must be a double-quoted string too:{"name": "x"}. - Missing comma — items on separate lines still need a comma between them. Pretty formatting makes these easy to spot once earlier errors are fixed.
- Comments — standard JSON doesn’t allow
//or/* */notes. Handy as they are in JavaScript, here they break the parse. - Unescaped characters — a quote, backslash or line break inside a string must be escaped as
\",\\or\n. The escape box on the tool page does this for you. - Mismatched brackets — every
{needs its}and every[its], closed in the right order. Formatting a fixed file makes nesting mistakes visible at a glance.
Fix one error, validate again, repeat. Parsers stop at the first problem they meet, so a file with three mistakes needs three rounds — that’s normal, not a sign you’re doing it wrong.

Common JSON Mistakes
- Pasting secrets into random online tools. Config JSON can contain API keys and tokens. Only use formatters that process text in your browser — as this one does — rather than sending it to a server you know nothing about.
- Reading “valid” as “correct”. A green tick means the grammar is legal. It says nothing about whether the values are right, complete, or the ones you meant.
- Editing the minified original in place. One slip in a one-line file is nearly invisible. Format a copy, do your reading and editing there, then minify again if the destination needs it.
- Bringing JavaScript habits with you. Comments, single quotes and trailing commas are all legal in the JavaScript you may have seen — and all illegal in JSON.
- Fixing only the flagged line. Because errors surface one token late, the flagged line is often innocent; the culprit is the line above it.
Frequently Asked Questions
Is JSON the same as JavaScript?
No — close relatives, not twins. JSON grew out of JavaScript’s object syntax, but it’s a stricter, language-independent data format; almost every programming language can read and write it. Things JavaScript allows — single quotes, comments, trailing commas — are all illegal in JSON, which is why code copied from a script often fails a validator.
Can a formatter repair my broken JSON automatically?
No — and be wary of any tool that promises to. A formatter validates the syntax and locates the error: the message, the line and column, and the offending line. You make the edit. That’s deliberate: an automatic “repair” would have to guess what you meant, and a wrong guess silently changes your data.
Is it safe to paste private JSON, like a config file, into this tool?
Yes, in this case: the tool runs entirely in your browser using its built-in JSON parser, so your text is never uploaded, sent or stored. The general rule still stands — never paste keys or tokens into a formatter that ships your text off to a server. If a tool doesn’t say where the processing happens, assume the worst.
What’s the difference between formatting and validating?
Validating answers one question: is this legal JSON? Formatting does the validation first — invalid JSON can’t be formatted at all — and then reprints the data indented and colour-highlighted so you can read it. Think of validation as the pass/fail test and formatting as the test plus a tidy, readable copy.
My JSON is valid, but my schema still fails Google’s test. Why?
Because they’re different checks. A formatter confirms the grammar of your JSON-LD; Google’s rich results testing also checks that the specific schema type has its required properties with sensible values. Valid syntax with a missing required field sails through a formatter and fails at Google. Fix the syntax here first, then check the required fields for your schema type.
Final Thoughts
Most JSON problems turn out to be one-character problems wearing a scary disguise — a comma that shouldn’t be there, a quote of the wrong kind, a bracket left open. You rarely need to understand the whole file; you need to find the one wrong character quickly, understand why it’s wrong, and fix it yourself. That’s precisely the loop the json formatter is built for: paste, get a verdict with a line number, fix, validate again.
Keep your originals untouched, work on copies, and let the machine do the squinting — that’s what it’s for.







