Format messy JSON, validate syntax, and beautify output instantly—perfect for developers and APIs.
Format JSON online instantly with this fast, free JSON formatter and validator. Ideal for developers working with APIs, config files, and debugging workflows.
Validate, minify, or beautify JSON in seconds. This JSON formatter works as a JSON beautifier for messy payloads, and it runs entirely in your browser for maximum speed and privacy—no upload required.
Used by developers to format and debug JSON data quickly and efficiently.
By EverydayTools Team ·
0 characters
Tip: Paste your JSON and click Format to beautify it, or Validate to check for errors. Use Minify to compress JSON for production use.
⭐ Bookmark this page to quickly format JSON anytime.
Advertisement
What is JSON?
JSON (JavaScript Object Notation) is a lightweight, text-based data format used for storing and exchanging structured data. Originally derived from JavaScript, it is now language-independent and supported by virtually every programming language — from Python and Java to PHP, Go, and Rust. The format is defined by RFC 8259 and is the dominant data format for REST APIs, configuration files, and web services worldwide.
JSON represents data as key-value pairs inside curly braces {}, and ordered lists inside square brackets []. It supports six data types: strings, numbers, booleans (true/false), null, objects, and arrays. Its simplicity is why it replaced XML as the dominant data-interchange format on the web.
Data types: string, number, boolean, null, object, array
File extension:.json
MIME type:application/json
Keys must be: strings enclosed in double quotes
Trailing commas: not allowed (common source of parse errors)
What is a JSON Formatter?
A JSON formatter is a tool that takes raw, minified, or badly indented JSON and renders it with consistent indentation and line breaks, making it easy for humans to read. It is also called a JSON beautifier or JSON pretty-printer. Beyond aesthetics, a good JSON formatter also validates syntax — it tells you exactly where an error is (line and column number) when your JSON is malformed.
This tool formats JSON entirely in your browser. Nothing is uploaded to a server, which matters when the JSON contains API keys, authentication tokens, or personal data. It also means it works instantly, with no round-trip network delay.
How to Format JSON Online (Step-by-Step)
Paste your JSON — Copy the raw or minified JSON from your API response, config file, or log and paste it into the input field above.
Choose indentation — Select 2 spaces (common in JavaScript and web projects) or 4 spaces (common in Python and Java projects). Both produce valid, readable JSON.
Format automatically — The formatter runs automatically as you type. Click Format JSON to manually trigger formatting if needed.
Check for errors — If your JSON is invalid, the tool highlights the exact line and column number of the syntax error so you can fix it quickly.
Copy or download — Click Copy to copy the formatted output to your clipboard, or Download to save it as a .json file.
Minify when done — Use Minify JSON to compress it back to a single line for production payloads or storage.
Advertisement
Example of JSON Formatting
Below is an example of messy JSON converted into a clean, readable format using this JSON formatter:
Messy JSON
{"name":"John","age":30,"city":"NY"}
Formatted JSON
{
"name": "John",
"age": 30,
"city": "NY"
}
Try formatting your own JSON above to see the difference instantly.
Common Use Cases for a JSON Formatter
Debugging REST API Responses
When you use fetch(), Postman, or curl to call an API, the response is often a single minified line. Pasting it into this formatter instantly expands it into a readable structure so you can identify which field contains unexpected data or which key is missing.
Editing Configuration Files
Tools like package.json, tsconfig.json, eslintrc.json, and VS Code settings.json are all JSON. When a config gets messy or throws a parse error, this formatter validates it and pinpoints the exact broken line.
Inspecting JWT Tokens
A JWT payload is Base64-encoded JSON. After decoding it (use our JWT Decoder), you can paste the payload here to read and validate the claims structure cleanly.
Reviewing Webhook Payloads
Stripe, GitHub, Shopify, and most modern SaaS platforms send webhook data as JSON. When troubleshooting a missed event or an unexpected field, paste the raw webhook body here to see the exact structure in seconds.
Data Migration and ETL Pipelines
When migrating data between systems, JSON files often arrive malformed or with inconsistent indentation. This formatter validates and normalizes the structure before you feed it into a database import or transformation script.
Preparing JSON for Code Reviews
When writing tests or adding fixture data, properly formatted JSON is much easier for reviewers to understand. Run it through this formatter before committing so diffs are clean and readable.
JSON Syntax Rules — What Makes Valid JSON
JSON has strict syntax rules. These are the most common causes of invalid JSON:
Rule
Valid
Invalid
Keys must be strings
"name": "John"
name: "John"
No trailing commas
[1, 2, 3]
[1, 2, 3,]
No comments
{"key": "val"}
{"key": "val"} // comment
Use double quotes
"name": "Alice"
'name': 'Alice'
Boolean lowercase
{"active": true}
{"active": True}
JSON vs XML vs YAML — Which Should You Use?
JSON is the dominant format for APIs and web services, but it is worth understanding when XML and YAML are preferable:
Format
Best For
Drawback
JSON
REST APIs, web apps, config files
No comments, no schema by default
XML
SOAP services, document formats, namespaces
Verbose, harder to read and parse
YAML
CI/CD configs (GitHub Actions, Docker Compose)
Indentation-sensitive, easy to break
Tips for Working with JSON Efficiently
Validate before parsing in code: Always validate JSON from external sources before parsing. A single malformed character crashes JSON.parse() — use try/catch or a validator first.
Use 2-space indentation for web projects: Most linters (ESLint, Prettier) default to 2 spaces for JSON in JavaScript projects. Use 4 spaces if your team or codebase is Python-heavy.
Minify for production, format for development: Serve minified JSON in API responses to reduce payload size. Keep formatted JSON in source files so diffs are readable.
Use JSON Schema for validation: For complex APIs, define a JSON Schema (a JSON document that describes the expected structure). Use our JSON Schema Generator to auto-generate one from sample data.
Avoid deeply nested JSON: JSON more than 4-5 levels deep is hard to debug. Flatten the structure where possible or split into separate API calls.
Watch for number precision: JSON numbers have no fixed precision. Very large integers (over 2^53) may lose precision in JavaScript. Use strings for IDs and large numeric values.
Why Use This JSON Formatter?
100% private — runs in your browser; your JSON data is never uploaded or stored
Instant validation — detects errors with exact line and column numbers
Format, minify, and copy — three operations in one tool, no switching tabs
Auto-formats as you type — no need to click a button; results appear in real time
Free, no signup, no limits — use it as many times as needed
Related JSON Tools for Developers
Explore more tools to validate, compare, and work with JSON data efficiently.
Before formatting transformed text payloads, validate the replacement logic in Regex Tester.
JSON Formatting: Key Concepts
JSON (JavaScript Object Notation)
A lightweight, text-based data interchange format defined by RFC 8259. JSON represents data as key-value pairs (objects) and ordered lists (arrays). It is language-independent and the de facto standard for REST API responses.
JSON Formatting (Beautifying)
The process of adding consistent indentation and line breaks to minified or compact JSON, making it human-readable. A formatter does not change the data — it only changes whitespace.
JSON Minification
Removing all unnecessary whitespace (spaces, tabs, newlines) from JSON to reduce file size. Minified JSON is harder to read but faster to transmit over a network. Use minified JSON in production API payloads.
JSON Validation
Checking that a JSON string conforms to the JSON syntax rules: properly quoted keys, correct use of commas, matching brackets and braces, and no trailing commas. Invalid JSON cannot be parsed by JSON.parse().
Indentation
The number of spaces (typically 2 or 4) used to indent each nested level of a JSON object or array. The JSON spec does not mandate a specific indentation — it is a formatting convention.
Ready to format JSON?
Use the tool above to format, validate, or minify JSON instantly.
Concise answers for common searches — definitions, steps, and comparisons.
What are the valid data types in JSON?
JSON supports exactly six value types: string (double-quoted), number (integer or decimal, no quotes), boolean (true or false, lowercase), null, object ({key: value} pairs), and array ([value, value]). JSON does not support: undefined, functions, Symbol, NaN, Infinity, single-quoted strings, or comments. A key that maps to undefined is silently dropped by JSON.stringify() — use null instead.
What characters must be escaped inside a JSON string?
Inside a JSON string, these characters must be escaped with a backslash: " (double quote → \"), \ (backslash → \\), and control characters (newline → \n, tab → \t, carriage return → \r, form feed → \f, backspace → \b). Unicode escapes use \uXXXX notation. Unescaped control characters cause a SyntaxError.
How do I minify JSON to reduce an API payload size?
Minification removes all whitespace between tokens: JSON.stringify(JSON.parse(input)) returns compact JSON with no spaces or line breaks. A typical well-indented JSON object compresses 15–30% by minification. For a REST API that transfers hundreds of KB per request, minification reduces bandwidth and speeds parsing. The data is structurally identical — only whitespace is removed.
How to use JSON Formatter
1
Paste your JSON
Copy raw JSON from an API response, log output, or config file and paste it. The formatter accepts minified single-line JSON, partially indented JSON, and will flag broken JSON.
2
Choose indentation
Select 2 spaces (JavaScript/TypeScript convention) or 4 spaces (Python/Java convention). Both produce valid, equivalent JSON — choose based on your project's style guide.
3
Review validation feedback
If your JSON is invalid, the error message shows the exact line and column of the syntax problem. Fix errors before copying to avoid downstream parsing failures.
4
Copy, download, or minify
Click 'Copy' to grab formatted JSON, 'Download' to save as a .json file, or 'Minify' to compress the output back to a single line for production payloads.
Who uses JSON Formatter?
Common real-world scenarios where this tool saves time.
Debugging API responses
Paste raw minified API output to instantly see the nested structure and identify missing or unexpected fields. Works with any REST or GraphQL response body.
Validating config files before committing
Validate package.json, tsconfig.json, .eslintrc, manifest.json, or any JSON config before committing — catches trailing commas, missing brackets, and unquoted keys before CI fails.
Reviewing webhook payloads
Stripe, GitHub, and Shopify webhooks arrive as minified JSON. Format them to trace missed events, verify payload structure, and identify which fields triggered your handler logic.
Data migration and ETL prep
Normalize inconsistent JSON from external data sources before feeding into an ETL pipeline, database import, or transformation script — catches malformed records before they reach production.
Workflow guides
Step-by-step chains that connect related tools for common tasks.
API debugging: validate before you format
When a REST API response looks broken, confirm syntax before prettifying — formatting invalid JSON does not fix parse errors and can hide the failure point.
Paste the raw response into JSON Validator to get the exact line and column of any syntax error.
Once valid, prettify the payload here (or paste the corrected string from the validator).
If the payload includes access_token or a JWT string, open JWT Decoder to inspect claims and exp (Unix timestamp).
For created_at, updated_at, iat, or exp fields, convert Unix timestamps with Timestamp Converter — 10 digits = seconds since epoch (POSIX), 13 digits = milliseconds (JavaScript Date.now()).
To pull IDs or timestamps from unstructured log lines before parsing JSON, test a pattern in Regex Tester , then paste captured values into the converter.
Config review before commit
Validate package.json, tsconfig.json, or manifest files in JSON Validator first.
Format the valid file here with 2-space indent to match Prettier and npm defaults.
Compare two environment configs with JSON Diff when you need a field-level change list between staging and production.
The formatted output reveals the nesting depth — user is an object containing id, email, and a roles array. The raw minified version requires scanning for brackets to understand the same structure. Formatting is the first debugging step when an API returns unexpected data.
Catch a trailing comma syntax error
Input
{"name": "alice", "active": true, "score": 98,}
Output
SyntaxError: Unexpected token } — line 1, column 46
Trailing commas after the last property are valid JavaScript but invalid JSON. This is the most common cause of JSON.parse() failures when copy-pasting object literals from JS code into API request bodies or config files.
How JSON formatting works
The formatter passes input to the browser's native JSON.parse(), which throws a SyntaxError with the byte offset of the first invalid character. On success, JSON.stringify(parsed, null, indentSize) re-serializes the structure with configurable indentation. Minification calls JSON.stringify(parsed) with no indent argument. Both operations run entirely in the JavaScript main thread and are O(n) in input length.
Formula
Format: JSON.stringify(JSON.parse(input), null, indentSpaces)
Minify: JSON.stringify(JSON.parse(input))
Error: SyntaxError at byte N → converted to line:column
Limitations
Key ordering is not guaranteed by ECMA-404 — V8 preserves insertion order for string keys in practice but this is not spec-mandated
Integers larger than Number.MAX_SAFE_INTEGER (2^53 − 1 = 9,007,199,254,740,991) lose precision when parsed as JavaScript numbers
Comments and trailing commas are invalid JSON — use a JSONC-aware parser for tsconfig.json and VS Code settings files
JSON is the default for programmatic data exchange. YAML is dominant in DevOps tooling. XML is mostly legacy except in enterprise and document-centric contexts.
You have a raw JSON API response to format and explore — including any string fields that happen to be tokens.
You have identified a JWT token string inside the JSON payload (the value of an 'access_token', 'token', or 'authorization' field) and need to decode its header and claims.
You need to format the full JSON response and see which fields contain Unix timestamps.
You have identified a numeric Unix timestamp field (created_at, updated_at, iat, exp) in the formatted JSON and want to convert it to a readable date.
Best practices
Always format API responses before debugging
Minified JSON forces you to count brackets to find nesting depth. Formatting takes one second and eliminates most of the cognitive overhead when a field is missing or the structure is deeper than expected.
Use 2-space indent for JavaScript and TypeScript projects
Prettier, ESLint, and npm defaults all use 2-space indent. Consistent indentation reduces diff noise in code reviews and aligns config files with the rest of the codebase.
Minify before embedding JSON in application bundles
A 100 KB config with 2-space indent is approximately 70 KB minified — a 30% reduction. Minified JSON parses marginally faster and reduces network transfer in API responses.
Validate every JSON config file before committing
Trailing commas, missing brackets, and JSONC comment syntax are the top causes of CI build failures in package.json, tsconfig.json, and manifest.json. A 3-second validation prevents a 3-minute CI queue wait.
Common mistakes to avoid
Single-quoted strings instead of double quotes
JSON requires double quotes for all keys and string values. {name: 'alice'} is valid JavaScript but invalid JSON. Use double quotes: {"name": "alice"}. The formatter shows the exact character position of the error.
Trailing comma after the last element
[1, 2, 3,] and {"a": 1,} are invalid JSON, though they are valid JavaScript. Remove the comma after the final item. This is the most common source of JSON.parse() errors when copying from JS files.
Including comments in .json files
JSON does not support // or /* */ comments. They work in JavaScript and TypeScript's tsconfig.json (which uses JSONC format), but not in files parsed by JSON.parse(). Move comments to external documentation or use a JSONC parser.
Using undefined instead of null for absent values
JSON.stringify() silently drops object properties set to undefined and converts undefined array items to null. The result looks like the property never existed. Use null for intentionally absent values: { "result": null }.
BOM character at the start of a .json file
Windows Notepad and some export tools prepend a UTF-8 BOM (\uFEFF) when saving. The character is invisible in most editors but causes JSON.parse() to throw 'Unexpected token' in Node.js and strict server parsers. Always save JSON files as UTF-8 without BOM.
Troubleshooting
JSON.parse() still fails in my code after the formatter says it's valid
Likely cause: BOM character (\uFEFF) at the start of the string — common in JSON files saved by Windows Notepad
Fix: Strip the BOM before parsing: input.replace(/^\uFEFF/, ''). The browser JavaScript engine accepts BOM-prefixed input silently; Node.js and strict server parsers do not.
Fix: Store large IDs and 64-bit timestamps as strings in JSON: { "id": "9007199254740993" }. The Twitter and Discord APIs both use this pattern for their ID fields.
Formatted JSON is valid but the API rejects it with a 400 error
Likely cause: JSON body is double-encoded (a string containing JSON), Content-Type header is missing, or a BOM was introduced during copy-paste
Fix: Verify Content-Type: application/json is set. Confirm the raw body is the JSON string directly, not URL-encoded or wrapped in another layer of quotes.
Key order changed after formatting
Likely cause: V8 sorts integer-like string keys numerically before other string keys — a non-obvious engine behavior
Fix: JSON key order is not guaranteed by the ECMA-404 spec. If your API or snapshot test depends on key order, sort keys explicitly in the producing code rather than relying on JSON.stringify output order.
A property I expected is missing from the formatted output
Likely cause: undefined, functions, and Symbol values are silently stripped by JSON.stringify — they have no JSON representation
Fix: Replace undefined with null before serializing. JSON.stringify({ a: undefined }) returns {} — the key disappears entirely. Use null for intentionally absent values: { "a": null }.
Advertisement
Frequently Asked Questions
Does it upload my JSON to a server?
No. All formatting and validation runs locally in JavaScript inside your browser. Your data never leaves your device — safe for API keys, tokens, database credentials, internal service configs, and any sensitive data.
What JSON syntax errors does it detect?
Trailing commas after the last element, unmatched braces and brackets, single-quoted strings, unquoted keys, missing commas between items, invalid Unicode escape sequences (\uXXXX), and invalid number formats. Each error reports the exact line and column number.
What is the difference between JSON and JavaScript object syntax?
JavaScript objects allow unquoted keys ({name: 'alice'}), single-quoted strings, trailing commas, and comments. JSON requires double-quoted keys ({"name": "alice"}), no trailing commas, and no comments. All valid JSON is valid JavaScript, but not vice versa — this mismatch is the source of most copy-paste errors.
Can it handle large JSON files?
Yes. Processing runs locally so there is no upload size limit or server timeout. Most JSON under 10 MB formats instantly. Files above 50 MB may take a few seconds depending on your device.
What is the difference between formatting and minifying?
Formatting adds indentation and line breaks for human readability. Minifying removes all whitespace to reduce file size — typically 15–30% smaller — for production API payloads and bundle assets. This tool handles both: format for debugging, minify for deployment.
Is this JSON formatter free?
Yes — completely free, no signup required, no usage limits. It runs entirely in your browser.
Privacy, accuracy, and trust
Privacy
All formatting, validation, and minification runs in your browser using the JavaScript engine. No data is ever sent to any server — safe for API keys, tokens, database credentials, and any sensitive payload.
Accuracy
Formatted output is semantically identical to input. The tool uses the same JSON.parse / JSON.stringify pipeline as Node.js and all major browsers. There is no custom parser or transformation.
Formatted output is for human readability only. Validate JSON before using in production systems.