Skip to main content

JSON Formatter & Validator

Format, validate, and beautify JSON with syntax highlighting.

Input

Output

Valid
{
  "name": "John Doe",
  "age": 30,
  "email": "john@example.com",
  "address": {
    "street": "123 Main St",
    "city": "New York",
    "state": "NY",
    "zip": "10001"
  },
  "hobbies": [
    "reading",
    "hiking",
    "photography"
  ],
  "active": true
}

Type

Object

Top-Level Keys

6

Formatted Size

264 B

Minified Size

194 B

Powered by CalcRun

How it works

What Is JSON?

JSON (JavaScript Object Notation) is a lightweight data format for storing and exchanging structured data. It uses human-readable text with two primary structures: objects (key-value pairs wrapped in curly braces) and arrays (ordered lists wrapped in square brackets).

Despite its name, JSON is language-independent — it’s used in virtually every programming language: Python, Java, Go, Ruby, C#, PHP, and more. It’s the default format for REST APIs, configuration files, data storage, and inter-service communication across the web.

Key takeaway: If you work with web APIs, cloud services, or modern software of any kind, you will encounter JSON. Learning to read and debug it is a fundamental developer skill.

Formatting vs Validation

Formatting (also called beautifying or pretty-printing) takes syntactically valid JSON and adds indentation, line breaks, and consistent spacing to make it easy to read. Minified API responses or one-line config files become instantly readable.

Validation checks whether a string is valid JSON according to the specification. Common errors include trailing commas (not allowed), single quotes instead of double quotes, unquoted keys, comments (JSON has no comment syntax), and mismatched brackets.

Our tool does both simultaneously — it formats valid JSON and flags errors in invalid JSON with the exact line and character position.

Tip: Paste your JSON into the tool before filing a bug report or asking for help. A clean, formatted snippet communicates the problem far faster than a minified blob.

Common JSON Errors and How to Fix Them

ErrorExampleFix
Trailing comma{"a": 1, "b": 2,}Remove the comma after the last item
Single quotes{'name': 'Alice'}Use double quotes: {"name": "Alice"}
Unquoted keys{name: "Alice"}All keys must be double-quoted: {"name": "Alice"}
Comments{"port": 8080 // default}JSON has no comment syntax — remove them
Missing commas{"a": 1 "b": 2}Add a comma between key-value pairs

Example: The most common error we see is trailing commas. JavaScript allows them, but JSON does not — if you copy an object literal from your code, strip the trailing commas before pasting.

Beautify vs Minify

Beautify adds whitespace for readability — use this when reading, debugging, or documenting JSON. Choose 2-space or 4-space indentation based on your project’s convention.

Minify removes all unnecessary whitespace — use this when sending JSON over a network or storing it efficiently. A well-structured 50-line JSON file might compress to a single line, reducing file size by 30-50%.

Tip: Use beautified JSON during development and minified JSON in production. Most build tools and API gateways can handle this automatically, but for quick one-off tasks, paste it here.

Privacy

This tool processes everything in your browser. Your JSON data is never sent to our servers — paste sensitive API responses, credentials in config files, or proprietary data without concern. You can verify this by using the tool while offline.

Real-World Examples

1

Debugging an API response

Json: {"status":200,"data":{"users":[{"id":1,"name":"Alice"},{"id":2,"name":"Bob"}]},"meta":{"total":2,"page":1}} Indent: 2

A developer receives a minified API response and can't read the nested structure. Pasting it into the formatter instantly reveals the hierarchy: a status code, a data object containing a users array with two entries, and a meta object with pagination info. The 2-space indentation makes the nesting levels clear at a glance.

2

Finding a syntax error in config

Json: {"database": {"host": "localhost", "port": 5432, "name": "myapp",}} Indent: 2

A configuration file won't parse and the developer can't spot the issue. The validator flags the trailing comma after the last key-value pair — JSON doesn't allow trailing commas, unlike JavaScript. The error message points to the exact line and character position, making the fix immediate.

3

Preparing data for documentation

Json: {"endpoint":"/api/v2/users","method":"GET","headers":{"Authorization":"Bearer token","Content-Type":"application/json"},"response":{"200":{"description":"Success"},"401":{"description":"Unauthorized"}}} Indent: 4

A technical writer needs a clean JSON example for API documentation. The formatter with 4-space indentation produces a well-structured, readable example that can be pasted directly into docs. Sorting keys alphabetically (optional) ensures consistent formatting across all code examples in the documentation.

Frequently Asked Questions

What is JSON?
JSON (JavaScript Object Notation) is a lightweight data format used to store and exchange data between systems. It uses human-readable text with key-value pairs and arrays. Nearly every web API, configuration file, and data exchange on the internet uses JSON. It looks like this: {"name": "CalcRun", "type": "tool"}.
What is the difference between JSON formatting and validation?
Formatting (also called beautifying or pretty-printing) takes valid but messy JSON and adds proper indentation and line breaks so it's easy to read. Validation checks whether a JSON string is syntactically correct — matching brackets, proper quoting, valid data types. Our tool does both simultaneously.
Why does my JSON show a validation error?
Common JSON errors include: trailing commas after the last item in an array or object (not allowed in JSON), using single quotes instead of double quotes for strings, unquoted keys, missing commas between items, and comments (JSON doesn't support // or /* */ comments). Our validator pinpoints the exact line and character where the error occurs.
What is the difference between JSON and a JavaScript object?
JSON is a string format that follows strict rules: all keys must be double-quoted, strings must use double quotes, no trailing commas, no comments, no functions. A JavaScript object is a programming construct that's more flexible. JSON is based on JavaScript object syntax but is language-independent — it's used in Python, Java, Go, and virtually every programming language.
How do I minify JSON?
Minifying (or compacting) JSON removes all whitespace, line breaks, and indentation to reduce file size. This is useful for sending data over networks where every byte counts. Our tool offers both beautify (add whitespace for readability) and minify (remove whitespace for compactness) options.