What is JSON?
JSON (JavaScript Object Notation) is a lightweight, text-based data interchange format that has become the de facto standard for web APIs, configuration files, and data storage. Originally derived from JavaScript, JSON is now language-independent and supported by virtually every modern programming language through built-in libraries or third-party parsers.
A JSON document consists of two fundamental structures: objects (unordered collections of key-value pairs wrapped in curly braces) and arrays (ordered lists of values wrapped in square brackets). Values can be strings, numbers, booleans (true or false), null, or nested objects and arrays. This simplicity is what makes JSON so widely adopted — it is human-readable yet easy for machines to parse and generate.
Developers encounter JSON daily when working with REST APIs, GraphQL responses, package manifests like package.json, infrastructure-as-code templates, and NoSQL databases such as MongoDB and CouchDB. Understanding JSON structure is a foundational skill for modern software development.
Common JSON Syntax Errors
Despite its simplicity, JSON has strict syntax rules that trip up even experienced developers. The most frequent mistakes include:
- Trailing commas: Unlike JavaScript objects, JSON does not allow a comma after the last element in an object or array.
{"a": 1, "b": 2,}is invalid. - Single quotes: JSON requires double quotes for all strings and property names. Using single quotes like
{'name': 'value'}will fail parsing. - Unquoted keys: Every key in a JSON object must be a double-quoted string.
{name: "value"}is valid JavaScript but invalid JSON. - Comments: JSON does not support comments of any kind — no
//line comments and no/* */block comments. If you need comments, consider JSONC or JSON5. - Special number formats: Hexadecimal (
0xFF), leading zeros (07), and positive sign prefixes (+1) are all invalid in JSON. Only standard decimal notation and scientific notation (e.g.,1.5e10) are allowed.
Our JSON formatter catches all of these errors and reports the exact line and character position, so you can fix problems in seconds instead of hunting through hundreds of lines of data.
JSON vs YAML
JSON and YAML are both popular serialization formats, but they serve somewhat different use cases. JSON is stricter and more predictable — its rigid syntax means fewer ambiguities and faster parsing. YAML, on the other hand, prioritizes human readability with indentation-based nesting, support for comments, and more flexible value types.
In practice, JSON dominates in API communication and programmatic data exchange where parsing speed and unambiguous structure matter. YAML is preferred for configuration files (Kubernetes manifests, CI/CD pipelines, Ansible playbooks) where humans frequently read and edit the files by hand.
One key advantage of JSON is its round-trip safety: parsing and re-serializing JSON always produces the same output. YAML's flexibility can introduce subtle bugs — for instance, the string no may be interpreted as a boolean false, and 3.10 may be parsed as the number 3.1. These gotchas make JSON the safer choice for machine-to-machine communication.
Frequently Asked Questions
What does a JSON formatter do?+
A JSON formatter takes raw or minified JSON data and restructures it with consistent indentation, line breaks, and spacing. This makes the data far easier to read, debug, and understand. Most formatters also validate the JSON and highlight syntax errors.
Is it safe to paste sensitive JSON data into an online formatter?+
With Pickbox, yes. Our JSON formatter runs entirely in your browser using JavaScript. Your data is never sent to a server, stored, or logged. Everything is processed client-side, so your API responses, configuration files, and tokens stay on your device.
What is the difference between JSON.stringify and a JSON formatter?+
JSON.stringify() is a JavaScript method that converts a JavaScript object into a JSON string. A JSON formatter takes an existing JSON string and reformats it for readability. Under the hood, most formatters use JSON.parse() followed by JSON.stringify(value, null, 2) to produce indented output.
Why is my JSON invalid?+
Common reasons include trailing commas after the last property, single quotes instead of double quotes, unquoted property names, missing commas between items, and comments (JSON does not support comments). Our formatter highlights the exact line and position of the error to help you fix it quickly.
Can I convert JSON to YAML or other formats?+
Our JSON formatter focuses on formatting and validating JSON. For converting between JSON, YAML, TOML, and other serialization formats, we plan to add dedicated converter tools in the future. In the meantime, you can validate your JSON here before converting it elsewhere.
Built With
This tool uses no external packages — just built-in browser APIs.