Free Tools
By Fadhil Abdulla

How to Format and Validate JSON (and Fix the 6 Most Common Errors)

Why JSON breaks, how to read a validator's error message, and a quick routine for pretty-printing, minifying and fixing JSON from APIs, logs and config files.

Editorial disclosure: Pyalm publishes and maintains the products and free tools discussed on this site. Regulatory statements are linked to primary sources where applicable. No independent professional review is claimed unless a reviewer is explicitly named.

JSON is the language APIs, webhooks, config files and logs use to exchange data. It is deliberately strict — and that strictness is why a single stray comma can break an integration. This guide covers how to format JSON so you can read it, how to validate it, and how to fix the errors you'll meet most often.

Format, validate, minify: what each one does

Action What it does When to use it
Format (pretty-print) Adds indentation and line breaks Reading an API response, reviewing a config
Validate Checks the text is legal JSON and reports the first error Before you save a config or send a request
Minify Removes all unnecessary whitespace Storing or sending JSON as compactly as possible
Sort keys Orders object keys alphabetically Comparing two payloads by eye

All four leave the data unchanged — only the presentation differs.

How to format JSON in three steps

  1. Open the free JSON Formatter & Validator.
  2. Paste your JSON. It is validated as you type.
  3. Choose 2 spaces, 4 spaces, tabs or Minify, then copy or download the result.

Everything runs in your browser, so you can safely paste responses that contain customer data or tokens.

The 6 most common JSON errors

1. Trailing commas

{"a": 1, "b": 2,} — JavaScript allows the final comma; JSON does not. Delete it.

2. Single quotes

{'name': 'Aisha'} is not JSON. Keys and strings must use double quotes: {"name": "Aisha"}.

3. Unquoted keys

{name: "Aisha"} works in JavaScript objects but not JSON. Quote every key.

4. Comments

JSON has no comments. Remove // ... and / ... /, or move notes into a "_comment" field if you must.

5. Unescaped characters in strings

A raw line break or tab inside a string is illegal. Use \n and \t. Backslashes in Windows paths need doubling: "C:\\Users".

6. Wrong value types

True, None and undefined (from Python or JavaScript) aren't JSON. Use true, false and null.

Reading a validator error

A good validator tells you the line and column of the first problem. The real mistake is often just before that position — a missing comma at the end of the previous line shows up as an "unexpected string" on the next one. Fix the first error, re-validate, and repeat; one mistake can hide others.

Tips for working with JSON every day

  • Sort keys before comparing two responses by eye — or use JSON Compare to diff them structurally.
  • Keep secrets out of shared JSON. Tokens in pasted payloads end up in chat logs and tickets.
  • Decode JWTs and Base64 separately. Tokens inside JSON often need the JWT Decoder or Base64 decoder.
  • Test the endpoint, not just the payload. The API Tester sends real requests and pretty-prints the response.

When JSON wrangling becomes a job

If your team spends hours each week reshaping JSON between systems — exporting from one app, fixing fields, importing into another — that's an integration waiting to be built. Pyalm builds custom software and integrations and business automation that move data between your tools automatically, with validation built in.

JSON Formatter | JSON Compare | API Tester | JWT Decoder | All free tools

Keep reading

More from Pyalm

Oct 16, 2026

How to Compare Two JSON Files (Without Drowning in Diff Noise)

Text diffs flag reordered keys and whitespace as changes. Here's how a structural JSON comparison works, and how to use it to review API changes, configs and migrations.

Oct 16, 2026

Regex Cheat Sheet with Real Examples (Emails, Phones, Dates, UAE TRN)

A practical regular expression cheat sheet — the syntax you actually use, plus tested patterns for emails, UAE and Indian phone numbers, dates and tax numbers.

Oct 16, 2026

URL Encoding Explained: %20, + and When to Encode

What percent-encoding is, why spaces become %20, the difference between encodeURI and encodeURIComponent, and how to avoid double-encoding bugs.

Oct 16, 2026

Unix Timestamps Explained: Epoch Time, Seconds vs Milliseconds and Time Zones

What epoch time is, why it's the standard way to store dates, how to tell seconds from milliseconds, and how to avoid the time-zone bugs it causes.

Oct 16, 2026

Minify vs Beautify: What Code Minification Does and When to Use It

How minifying JavaScript, CSS and HTML shrinks files, how much it really saves, and when to beautify minified code to debug it.

Oct 16, 2026

Why You Should Test with Fake Data (and How to Generate It in Seconds)

Using real customer data in development is a privacy risk; using 'test123' hides bugs. Here's how realistic fake data helps — with regional formats for the UAE, India, US and UK.

Try the free JSON Formatter & Validator

Pyalm builds custom software, APIs and integrations for businesses in India and the UAE. We made these developer tools for our own team — use them free, and talk to us when you need something built.

Open JSON Formatter & Validator See custom software All free tools