Load Sample JSON
JSON Syntax Quick Reference
Common JSON Error Messages
| Error | Meaning | Fix |
|---|---|---|
| Unexpected token | An unexpected character was found | Check for single quotes, missing colons, or stray characters |
| Unexpected end of JSON input | The JSON is cut off or incomplete | Make sure all braces { } and brackets [ ] are closed |
| Trailing comma | Extra comma after the last item | Remove the comma after the last key-value pair or array item |
| Expected property name | Object key is missing or malformed | Wrap all object keys in double quotes |
| Unterminated string | A string value is missing its closing quote | Find and close all open string literals with a matching double quote |
What is JSON?
JSON (JavaScript Object Notation) is a lightweight text format for storing and exchanging data. Proposed by Douglas Crockford in the early 2000s, JSON became the most widely used data interchange format on the internet thanks to its simple, human-readable syntax that machines can parse with equal ease.
Unlike XML or CSV, JSON can represent complex nested data structures — objects containing arrays containing other objects — without verbose markup. This makes JSON the default choice for REST APIs, application configuration files, NoSQL databases like MongoDB, and settings storage in modern web applications.
JSON is standardized under RFC 8259 and ECMA-404. These standards define exactly what is valid — from how strings and numbers are written, to how objects and arrays are structured. Any deviation from the standard makes the JSON invalid and unparseable.
JSON Syntax Rules
JSON supports six data types:
- String: Must be enclosed in double quotes. Example:
"hello". Single quotes are not valid in JSON. - Number: Integer or decimal, positive or negative, supports scientific notation. Examples:
42,-3.14,1.5e10. - Boolean: Only
trueandfalse— always lowercase. - Null: The keyword
null(lowercase) represents an empty/absent value. - Object: A collection of key-value pairs inside curly braces
{}. Every key must be a string in double quotes. - Array: An ordered list of values inside square brackets
[], separated by commas.
What JSON does not allow: comments (neither // nor /* */), trailing commas after the last item, unquoted keys, and special JavaScript values like undefined, NaN, or Infinity.
Common JSON Errors and Fixes
1. Trailing Comma
The most common error among developers who write JSON by hand after working with JavaScript. JSON strictly forbids commas after the last element of an object or array. Prevention: always double-check the last item before } or ].
2. Unquoted Object Keys
In JavaScript you can write { name: 'Alice' }, but in JSON every key must have double quotes: { "name": "Alice" }. This is the source of many bugs when developers copy JavaScript object literals directly into a JSON file.
3. Comments in JSON
Standard JSON does not support comments of any kind. If you need comments in configuration files, consider YAML or TOML instead. Some editors support JSONC (JSON with Comments) as a non-standard extension, but it is not valid JSON.
4. Unterminated Strings
Occurs when a string value is cut off or missing its closing quote. Most often encountered when pasting content that contains unescaped double quotes inside a string — the fix is to escape inner quotes with a backslash: \".
JSON vs XML vs YAML
| Feature | JSON | XML | YAML |
|---|---|---|---|
| Human readability | Good | Medium | Excellent |
| Comments supported | No | Yes | Yes |
| File size | Small | Large | Medium |
| REST API standard | De facto standard | Limited | Rare |
| Config file usage | Common | Less common | Very popular |
Summary: JSON wins for REST APIs and web data exchange; YAML wins for configuration files (Kubernetes, Docker Compose, CI/CD pipelines); XML remains common in legacy enterprise systems (SOAP, RSS, XSLT).
Best Practices for Valid JSON
- Always use an editor with JSON syntax highlighting (VS Code, JetBrains IDEs) — errors are visually flagged immediately.
- Add a JSON linter step in your CI/CD pipeline — catch errors before they reach production.
- When generating JSON programmatically, use
JSON.stringify()(JavaScript) orjson.dumps()(Python) instead of manually concatenating strings. - Validate JSON after every manual edit — especially when adding or removing elements.
- Use consistent key naming: either
camelCaseorsnake_casethroughout a document, never mixed. - Avoid special characters in keys — while technically valid, they require bracket notation to access in code and are a common source of bugs.
Frequently Asked Questions
More Data Tools
JSON Formatter — Beautify, Minify & Validate JSON Online
Format, beautify, and minify JSON data with real-time validation. Configurable indentation (2/4/tab), instant error detection, copy and download. Free online JSON formatter for developers.
JSON Minifier — Compress JSON & Remove Whitespace Online
Minify JSON online by removing all whitespace and indentation. Shows before/after size comparison with savings percentage. Validates JSON before compressing to guarantee valid output. Includes prettify mode, download, and copy. Free, private, runs entirely in your browser.
JSON Diff and Compare — Find JSON Differences
Compare two JSON objects side-by-side and highlight structural differences. Added lines in green, removed in red. Normalizes key order for accuracy.
JSON to YAML Converter — Convert Config Files Online Free
Convert JSON to YAML and YAML to JSON instantly. Bidirectional converter with indent control, key sorting, and sample configs. Free, private, browser-based.
CSV to JSON Converter — Convert Spreadsheet Data Instantly
Convert CSV to JSON online with real-time preview. Supports comma, semicolon, tab, and pipe delimiters. 3 output formats. Free, private, runs in your browser.
XML Formatter & Validator — Prettify, Minify & Validate XML Online
Format and validate XML online with syntax highlighting, configurable indentation (2/3/4 spaces), and real-time error detection. Switch between prettify and minify modes. Uses the browser's native DOMParser — free, private, no data leaves your device.
About Data Converters
Developer tools automate the repetitive parts of software work: formatting JSON, encoding/decoding Base64, decoding JWTs to verify token claims, generating UUIDs, formatting XML, diffing configurations. These aren't glamorous tasks, but they're the friction points that eat 10-15 minutes multiple times a day — adding up to hours weekly. Running them in a clean browser tab beats wrestling with CLI dependencies or IDE extensions that might ship your private data to a third party.
Why it matters
Fast, client-side developer tools fundamentally matter because they're used with sensitive data. JWT tokens contain user identity. Base64 payloads might encode API keys. JSON dumps include customer records. If a 'developer tool' sends your input to a server to process, you've just leaked production secrets. ZestLab's dev tools run 100% client-side with no network calls after page load — what you paste stays in your browser.
Privacy and safety
All developer tools here execute in-browser using pure JavaScript. There's no 'decode server' or 'format API' — your JWT, your JSON, your encoded payload is parsed by code running on your laptop. Verify this yourself with browser DevTools → Network tab: you'll see zero outbound requests when using any tool. That's a standard we hold because dev tools handle secrets.
Best practices
- Never paste production JWT or API tokens into ANY online tool without verifying it runs client-side (check the Network tab)
- Use browser private/incognito mode for one-off decoding of sensitive payloads
- Bookmark tools you use daily — ZestLab tool URLs are stable and don't require accounts
- When formatting JSON with secrets for team review, redact credentials before sharing the formatted output