Everyday Tools
Search

What Is JSON and How to Format It

Last updated 2026-09-11

JSON (JavaScript Object Notation) is a lightweight, text-based format for structuring data — used everywhere from API responses to config files.

Understand the basic structure

JSON is built from objects (key-value pairs in curly braces), arrays (ordered lists in square brackets), strings, numbers, booleans, and null.

Follow the syntax rules strictly

Keys must be double-quoted strings. Values can be strings, numbers, booleans, null, objects, or arrays. Commas separate items but must not trail after the last one.

Use a formatter to catch errors

A formatter re-indents valid JSON for readability and flags exactly where syntax breaks — usually a missing comma, an unmatched bracket, or a trailing comma.

Example

Invalid: {name: "Ana", age: 30,} — unquoted key and a trailing comma. Valid: {"name": "Ana", "age": 30}.

Important Considerations

  • Unlike JavaScript object literals, JSON keys must always be in double quotes — single quotes and unquoted keys are invalid.
  • JSON does not support comments — any // or /* */ in a .json file will cause a parse error in strict parsers.
  • Trailing commas (after the last item in an object or array) are invalid JSON, even though many programming languages allow them.

Frequently Asked Questions

Can JSON have comments?
No — the JSON specification doesn't support comments. Some parsers tolerate them as an extension, but standard JSON does not.
Why does my JSON fail with a trailing comma?
JSON's grammar doesn't allow a comma after the final item in an object or array — remove it and the error goes away.

Related Tools

Related Guides