← All Articles · · 5 min read

JSON Formatter Online: Format, Validate, and Debug JSON Instantly

How to format, validate, and debug JSON online. Covers pretty printing, minifying, schema validation, and fixing common JSON errors — with a free online tool.

jsonjson-formatterjson-validatordeveloper-toolsweb-development

JSON Formatter Online: Format, Validate, and Debug JSON Instantly

Unformatted JSON is one of the most frustrating things to debug. A single missing comma or mismatched brace can break everything — and without proper formatting, it’s nearly impossible to spot.

A good online JSON formatter does three things: format, validate, and visualize.


What Is a JSON Formatter?

A JSON formatter (also called a JSON beautifier or pretty printer) takes compact or unreadable JSON and restructures it with consistent indentation and line breaks.

Before formatting:

{"user":{"id":1,"name":"Alice","roles":["admin","editor"],"settings":{"theme":"dark","notifications":true}}}

After formatting:

{
  "user": {
    "id": 1,
    "name": "Alice",
    "roles": [
      "admin",
      "editor"
    ],
    "settings": {
      "theme": "dark",
      "notifications": true
    }
  }
}

The same data — but now you can actually read it.


Format JSON Online Free

DevPlaybook JSON Formatter — paste your JSON, get formatted output instantly. No account, no server upload.

Features:

  • Pretty print with 2 or 4 space indentation
  • Minify/compact mode for production
  • Syntax highlighting
  • Collapsible tree view
  • Error detection with line numbers
  • Copy to clipboard in one click

How to Format JSON

In the Browser (Online Tool)

  1. Paste your JSON into devplaybook.cc/json-formatter
  2. Click “Format” (or it formats automatically)
  3. Copy the formatted output

In JavaScript

// Pretty print with 2-space indent
const formatted = JSON.stringify(data, null, 2);

// Minify
const minified = JSON.stringify(data);

// Parse and re-format (normalize)
const normalized = JSON.stringify(JSON.parse(jsonString), null, 2);

In Python

import json

# Pretty print
formatted = json.dumps(data, indent=2)

# From string
normalized = json.dumps(json.loads(json_string), indent=2)

# From file
with open('data.json') as f:
    data = json.load(f)
print(json.dumps(data, indent=2))

In the Terminal

# Using jq (install: brew install jq)
echo '{"a":1,"b":2}' | jq .

# Using Python (no install needed)
echo '{"a":1,"b":2}' | python3 -m json.tool

# Format a file
cat data.json | jq . > data-formatted.json

JSON Validation

Formatting is only useful if the JSON is valid. A JSON validator checks that your JSON follows the spec:

What Makes JSON Invalid?

  1. Trailing commas — not allowed in JSON (unlike JavaScript objects)

    // Invalid
    {"name": "Alice",}
    
    // Valid
    {"name": "Alice"}
  2. Single quotes — JSON requires double quotes

    // Invalid
    {'name': 'Alice'}
    
    // Valid
    {"name": "Alice"}
  3. Comments — JSON doesn’t support comments

    // Invalid
    {
      // This is a comment
      "name": "Alice"
    }
  4. Unquoted keys — all keys must be strings in double quotes

    // Invalid
    {name: "Alice"}
    
    // Valid
    {"name": "Alice"}
  5. Undefined / NaN / Infinity — these JavaScript values don’t exist in JSON

    // Invalid
    {"value": undefined}
    {"value": NaN}
    {"value": Infinity}
  6. Mismatched brackets — every { needs a }, every [ needs a ]

Reading JSON Error Messages

JSON.parse: unexpected character at line 3 column 12

Go to line 3, count to column 12. The error is usually one character before the reported position (the parser finds the problem after it’s already read past the culprit).


JSON Schema Validation

JSON Schema lets you define the structure your JSON must follow — field names, types, required fields, value constraints.

{
  "$schema": "http://json-schema.org/draft-07/schema",
  "type": "object",
  "required": ["id", "name"],
  "properties": {
    "id": { "type": "integer" },
    "name": { "type": "string", "minLength": 1 },
    "email": { "type": "string", "format": "email" },
    "age": { "type": "integer", "minimum": 0, "maximum": 150 }
  }
}

Use JSON Schema to:

  • Validate API request/response bodies
  • Document your data structures
  • Catch data quality issues early

JSON Minification

Minified JSON removes all whitespace to reduce file size. For large datasets or API responses, this reduces bandwidth.

Example:

// 147 characters formatted
{
  "user": {
    "id": 1,
    "name": "Alice"
  }
}

// 34 characters minified
{"user":{"id":1,"name":"Alice"}}

Use minification for:

  • Production API responses
  • localStorage / sessionStorage
  • Data files in web applications

Working with Large JSON Files

Online formatters sometimes struggle with very large JSON files. For files over 10MB:

# jq handles large files efficiently
jq . large-file.json > large-file-formatted.json

# Python (slower but always available)
python3 -m json.tool large-file.json > large-file-formatted.json

# Node.js (streams, for very large files)
node -e "
const fs = require('fs');
const data = JSON.parse(fs.readFileSync('large.json'));
fs.writeFileSync('large-formatted.json', JSON.stringify(data, null, 2));
"

JSON vs JSONC vs JSON5

JSON — the spec. Strict, no comments, no trailing commas.

JSONC (JSON with Comments) — used in VS Code settings, TypeScript configs. Allows // and /* */ comments.

JSON5 — more relaxed: single quotes, trailing commas, comments, unquoted keys. Used in some config formats.

Most validators only accept strict JSON. If your JSON has comments, it’s probably JSONC — remove comments before validating.


Common JSON Tools Compared

ToolWhereBest For
DevPlaybook JSON FormatterBrowserQuick formatting, no install
jqTerminalScripting, large files, querying
VS CodeEditorDev workflow, syntax highlighting
Python json.toolTerminalAlready installed everywhere

JSON in Modern Development

JSON is the lingua franca of web APIs. You’ll format JSON when:

  • Debugging API responses (copy from browser DevTools, paste into formatter)
  • Writing JSON config files
  • Working with data pipelines and ETL jobs
  • Storing configuration in databases

A good formatter is a tool you’ll use every week. Bookmark devplaybook.cc/json-formatter and you’ll have it when you need it.

Free Newsletter

Level Up Your Dev Workflow

Get new tools, guides, and productivity tips delivered to your inbox.

Plus: grab the free Developer Productivity Checklist when you subscribe.

Found this guide useful? Check out our free developer tools.