JSON formatter: validate and format JSON online
JSON (JavaScript Object Notation) is the standard data exchange format for modern web APIs. A JSON formatter converts compact or poorly indented JSON into readable code and validates its syntax to detect errors.
Common JSON errors
- Trailing commas in arrays or objects — not allowed in strict JSON.
- Single quotes instead of double quotes.
- Unquoted keys.
- Comments — JSON does not allow comments (use JSON5 if you need them).
- Undefined or NaN values — not valid JSON types.
JSON vs. JSON5 vs. JSONC
Standard JSON is very strict. JSON5 adds comments, trailing commas, and unquoted keys for better readability in config files. JSONC (JSON with Comments) is used by VS Code in its configuration files. For APIs, always use standard JSON.
Validation and security
Before running JSON.parse() in production, validate the input. Malformed JSON throws a SyntaxError. Using try/catch is sufficient for error handling. For public APIs, limit the size of accepted JSON to prevent denial-of-service attacks.