tooliv

JSON Formatter

Format, validate and minify JSON online

Indent

JSON Formatter

What's the difference between JSON and a JavaScript object?

JSON is a string format -- keys must be double-quoted, no functions, no undefined, no comments. JS objects are more flexible.

Can I put comments in JSON?

No, the JSON spec doesn't allow comments. Use JSONC format or strip comments before parsing.

Why does JSON have null but not undefined?

JSON is language-agnostic. undefined is a JavaScript concept; null is universal across languages.

JSON: The Format That Runs the Web

JSON (JavaScript Object Notation) is the de facto standard for data exchange on the web. Nearly every REST API returns JSON, configuration files use it, and databases like MongoDB store data in JSON-like documents. Understanding how to read and format JSON is a baseline skill for any developer.

Why JSON Validation Matters

A single misplaced comma or missing quote in a JSON file will break everything that depends on it. API calls fail, configuration files silently break, and debugging can take hours. A validator shows you exactly which line has the problem, saving you from the classic "why isn't this working" spiral.

JSON vs XML: Why JSON Won

XML was the dominant data format until the early 2000s. JSON replaced it because it's dramatically more compact -- the same data often takes 30-40% less space. More importantly, JavaScript can parse JSON natively (JSON.parse()), while XML requires a dedicated parser. When REST APIs became the standard for web services, JSON came with them.

When to Minify vs. Beautify

Beautified JSON (with indentation and newlines) is for humans -- reading configs, debugging API responses, reviewing data files. Minified JSON is for machines -- production API responses and config files where every byte counts. Removing whitespace from a typical JSON response shaves 10-30% off the size, which matters at scale when you're serving millions of requests per day.

JSON Schema: Enforcing Structure

JSON Schema lets you define what valid JSON looks like for your use case -- required fields, data types, string patterns, numeric ranges, allowed values. It's used in OpenAPI specifications, VS Code for config file autocomplete, and API validation libraries. Adding JSON Schema validation to your API means catching malformed data at the entry point rather than deep in your business logic.

Frequently Asked Questions

What's the difference between JSON and a JavaScript object?

JSON is a string format -- keys must be double-quoted, no functions, no undefined, no comments. JS objects are more flexible.

Can I put comments in JSON?

No, the JSON spec doesn't allow comments. Use JSONC format or strip comments before parsing.

Why does JSON have null but not undefined?

JSON is language-agnostic. undefined is a JavaScript concept; null is universal across languages.

Related Tools