JSON Formatter & Validator
Format, validate, and minify JSON data. 100% client-side — your data never leaves your browser.
No data sent to serverRelated Tools
What is JSON?
JSON (JavaScript Object Notation) is a lightweight, text-based data interchange format defined in RFC 8259 (December 2017, replacing RFC 7159). Originally derived from a subset of JavaScript syntax, JSON is now language-independent and supported natively by virtually every programming language. It dominates web APIs, configuration files, and inter-service messaging — accounting for ~90% of public REST API formats.
Why format JSON?
Raw JSON in production is typically minified (no whitespace) to save bandwidth. Machine-friendly, human-hostile. Pretty-printing with 2-space or 4-space indentation makes structure visible — essential for debugging API responses, reviewing config files, and understanding nested objects.
Why client-side processing matters
Online JSON formatters that POST your data to a server expose you to logging, retention, and unauthorized access risks. API tokens, customer PII, authentication payloads — these often need formatting but never leave your machine safely. This tool uses the browser's native JSON.parse and JSON.stringify — verifiable in DevTools Network tab (no requests when formatting).
How to Use This Tool
- Paste your JSON data into the input field on the left.
- Click Format (2 spaces) for compact pretty- print, or Format (4 spaces) for readable wider indent.
- Click Minify to compress JSON into a single line — useful for embedding in code or API testing.
- Click Validate to check if your JSON is valid; errors show with line/column information.
- Press
Ctrl+Enter/Cmd+Enteras a shortcut for formatting. - Click Copy to copy the formatted output.
JSON Syntax Rules (RFC 8259)
Six data types
- Object —
{}with key:value pairs - Array —
[]ordered list - String —
"..."double quotes only, with escapes - Number — integer or float, no leading zero, no NaN/Infinity
- Boolean —
trueorfalse(lowercase) - Null —
null(lowercase)
Strict requirements
✓ Valid JSON
{
"name": "Alice",
"age": 30,
"hobbies": ["coding", "reading"],
"active": true,
"address": null
}
✗ Invalid (common mistakes)
{
name: "Alice", // unquoted key
'age': 30, // single quotes
"hobbies": [ // trailing comma below
"coding",
"reading",
],
"active": True, // capitalized boolean
"comment": /* nope */ // comments not allowed
}Encoding
JSON files must be UTF-8 (RFC 8259 mandates Unicode). String escapes: \", \\, \n, \r, \t, \b, \f, \/, and \uXXXX for arbitrary code points. UTF-8 BOM is explicitly forbidden.
JSON variants
- JSONC — JSON with Comments (used by VSCode, TypeScript). Allows
//and/* */. NOT valid JSON. - JSON5 — looser superset (unquoted keys, trailing commas, single quotes). NOT valid JSON.
- JSON Lines / NDJSON — one JSON value per line. Used for streaming/log files.
- JSON Schema — schema definition language for JSON, used for API validation.
Common JSON Pitfalls
1. Trailing commas
[1, 2, 3,] is invalid JSON (allowed in JS, allowed in JSON5, NOT in standard JSON). Many parsers produce confusing error messages on this.
2. Single quotes
JSON strings must use "double quotes" only. Many developers paste from JavaScript and forget — 'value' throws an error.
3. Numeric precision (Number.MAX_SAFE_INTEGER)
JavaScript represents numbers as 64-bit floats. Integers above 2⁵³ (9,007,199,254,740,992) lose precision — JSON.parse('9999999999999999') becomes 10000000000000000. For large IDs (Twitter snowflakes, PostgreSQL bigints), serialize as strings.
4. NaN and Infinity
JSON doesn't allow NaN, Infinity, or -Infinity. JSON.stringify(NaN) in JavaScript returns "null" silently — easy to miss in tests. Validate before serialization.
5. Date serialization
JSON has no native Date type. JSON.stringify(new Date()) produces an ISO 8601 string, but JSON.parse() gives back a string, not a Date. Use a custom reviver: JSON.parse(json, (k, v) => isoRegex.test(v) ? new Date(v) : v).
6. Comments are not allowed
Standard JSON forbids // and /* */. If you need comments in config files, use JSONC (VSCode pattern) or YAML/TOML instead.
Frequently Asked Questions
Is my data safe?
Yes. This tool runs entirely in your browser using native JSON.parse and JSON.stringify. No data is transmitted to any server — verify in DevTools Network tab.
What is the maximum JSON size I can format?
Limited by your device memory. Files up to 10 MB process instantly. 100 MB+ may freeze the browser briefly. For multi-GB JSON streams, use jq on the command line or stream parsers (JSONStream, oboe.js).
Can I use this tool offline?
Yes — once the page loads, all formatting works without internet. No external API calls.
What's the difference between JSON and JavaScript objects?
Every valid JSON is valid JavaScript object syntax, but not vice versa. JS objects allow unquoted keys, trailing commas, single quotes, comments, methods, and references — JSON allows none of these. JSON is strictly serializable; JS objects are runtime constructs.
Why does my JSON validator say "Unexpected token"?
Most common causes: trailing comma, single quotes, unquoted keys, missing closing brace/bracket, line breaks inside strings (need \n). Use this tool's Validate feature to get exact line/column.
⚠️ Reference Only
Output is generated based on your input and is provided for reference. Results may vary depending on your specific use case, edge cases, or environment-specific behavior. We do not guarantee accuracy of conversions, validations, or computed values.
Always verify critical outputs against official documentation or production environments. We are not responsible for any decisions or losses based on these tool results.
📖 Related Guides
Color Formats — HEX, RGB, HSL, OKLCH
Modern CSS color formats explained. When to use OKLCH for perceptual uniformity.
REST vs GraphQL vs gRPC — Choosing an API Paradigm
Trade-offs across performance, tooling, type safety, and team shape. When to use each.
UUID v4 vs ULID — Which to Choose?
Compare UUID v4 and ULID for distributed systems. Performance, sortability, and use cases.