DeveloperJune 8, 2026·4 min read

What is JSON and How to Format It — A Beginner's Guide

JSON is the language of the web. Whether you are building APIs, reading responses from a third-party service, or debugging a frontend app, you will encounter JSON constantly. This guide explains what it is, how it works, and how to format it cleanly in seconds.

Try the free JSON Formatter

Paste messy JSON and get it clean, readable, and validated instantly.

Open tool →

What is JSON?

JSON stands for JavaScript Object Notation. It is a lightweight, text-based format for storing and exchanging data. Despite the name, JSON is language-independent and is used in Python, Ruby, Go, Java, and virtually every other modern language.

JSON was popularised by Douglas Crockford in the early 2000s as a simpler alternative to XML. Today it is the default data format for REST APIs, configuration files, databases like MongoDB, and browser storage.

JSON Syntax — The Basics

JSON is built on two structures:

  • Objects — a collection of key/value pairs wrapped in curly braces
  • Arrays — an ordered list of values wrapped in square brackets

A simple JSON object looks like this:

{ "name": "Deepak", "age": 28, "isPremium": true, "tags": ["developer", "investor"], "address": { "city": "Mumbai", "pincode": "400001" } }

JSON Data Types

JSON supports exactly six data types:

TypeExample
String"hello"
Number42 or 3.14
Booleantrue or false
Nullnull
Object{ "key": "value" }
Array[1, 2, 3]

The Most Common JSON Errors

JSON syntax is strict. One misplaced character breaks the entire document. Here are the errors developers make most often:

1. Trailing commas

JSON does not allow a comma after the last item in an object or array. This is valid JavaScript but invalid JSON:

{ "name": "Deepak", "age": 28, } ← trailing comma

2. Single quotes instead of double quotes

All strings in JSON must use double quotes. Single quotes are not valid:

{ 'name': 'Deepak' } ← single quotes

3. Unquoted keys

Object keys must always be strings wrapped in double quotes:

{ name: "Deepak" } ← unquoted key

4. Comments

JSON does not support comments. Both // single line and /* block */ comments will cause a parse error.

Pretty Print vs Minified JSON

JSON can be formatted in two ways. Pretty-printed JSON uses indentation and line breaks to make it human-readable. Minified JSON strips all whitespace to reduce file size — useful for production API responses where bandwidth matters.

When debugging, you always want pretty-printed JSON. When shipping to production, minified is preferred. A good JSON formatter handles both in one click.

How to Format JSON Instantly

You do not need to install anything or write code. The free JSON Formatter lets you:

  1. Paste any raw or minified JSON into the input
  2. See it instantly formatted with proper indentation
  3. Validate it — any syntax errors are highlighted clearly
  4. Minify it back to a single line if needed
  5. Copy the result with one click

JSON vs XML — Why JSON Won

Before JSON, XML was the dominant data format for web services. JSON replaced it in most web contexts because it is significantly more compact, easier to read, and maps naturally to data structures in JavaScript and other languages. A JSON payload is typically 30–40% smaller than its XML equivalent.

Format and validate your JSON now

Free, instant, no signup needed.

Open JSON Formatter →