ToolsDock

What is JSON?

technology

Definition

JSON (JavaScript Object Notation) is a lightweight, text-based data format used to store and exchange structured data. It uses human-readable key-value pairs, arrays, and nested objects. JSON is the dominant data format for REST APIs, web applications, and configuration files. Valid JSON requires double-quoted keys and no trailing commas.

Detailed Explanation

JSON was derived from JavaScript syntax but is now language-independent — virtually every programming language has built-in JSON parsing support. A JSON object looks like: {"name": "ToolsDock", "tools": 69, "free": true}. Values can be strings, numbers, booleans, arrays, objects, or null.

JSON replaced XML as the dominant API data format because it is more compact, easier to read, and faster to parse. A REST API returning user data in JSON might look like: {"id": 1, "name": "Azam", "email": "contact@toolsdock.in"}.

Common JSON errors: trailing commas (allowed in JavaScript but invalid in strict JSON), single-quoted strings (must use double quotes), unquoted keys, and undefined values. Use ToolsDock's JSON Formatter to validate and format any JSON string instantly.

JSON syntax in two minutes

A JSON document is built from two structures: objects in curly braces holding key-value pairs, and arrays in square brackets holding ordered lists. Keys must be strings in double quotes. Values can be a string, number, true, false, null, an object or an array. Example: {"tool": "JSON Formatter", "free": true, "tags": ["dev", "data"]}.

JSON has no comments, no trailing commas, no single-quoted strings and no undefined. JavaScript object literals allow all of these, which is why code that works as a JavaScript object often fails as JSON.

Typical JSON errors and how to fix them

The usual suspects are a trailing comma after the last item, single quotes around strings, unquoted keys, missing commas between items, and unescaped double quotes or line breaks inside strings. Parsers report 'Unexpected token' with a position, which points near, but not always exactly at, the real mistake.

Paste the document into the JSON Formatter to validate it and pretty-print it with indentation. Reading nested data with clear indentation makes missing brackets easy to spot.

JSON compared with XML and CSV

JSON is lighter than XML, maps directly onto objects and arrays in most languages, and is the default format for web APIs. XML still wins where you need schemas, attributes and mixed content. CSV is smaller still for flat tables but cannot represent nested structure. Choose the format that matches the shape of your data.

When sending JSON over the wire, set the Content-Type to application/json and use UTF-8. Binary content such as images has to be turned into text first, commonly with Base64.

{ } JSON Formatter & Validator

Format & validate JSON data

Use Free Tool →

Frequently Asked Questions

What does JSON stand for?

JavaScript Object Notation. It originated from JavaScript syntax but is language-independent and supported by nearly every programming language.

Can JSON have comments?

No. The JSON standard does not allow comments. Some tools accept a relaxed variant such as JSONC or JSON5, but a strict parser will reject them.

Is JSON the same as a JavaScript object?

No. JSON is a text format with stricter rules. JSON.parse turns JSON text into a JavaScript object and JSON.stringify turns an object back into JSON text.