Developer

JSON Formatter & Validator Online

JSON (JavaScript Object Notation) is a lightweight, text-based format for exchanging structured data between systems, and this formatter helps you read, validate, and reshape it. Format and validate JSON instantly in your browser, no sign-up, nothing uploaded. Paste your JSON to beautify it with 2-space, 4-space, or tab indentation, minify it to a single line, or see a precise error with line and column number. Also converts to YAML, CSV, and XML, sorts keys alphabetically, and escapes or unescapes JSON strings.

JSON Input
Output, Beautify
Output appears here as you type…

100% private, all processing runs in your browser. Your JSON is never uploaded or stored.

What each mode does

Beautify

Re-formats JSON with readable indentation. Choose 2 spaces (default), 4 spaces, or a tab character. Best for reading API responses or editing config files.

Minify

Strips all whitespace and newlines. Produces the smallest valid JSON string, use for production API payloads, cookies, or local storage values.

YAML

Converts JSON to YAML format. Useful when moving config between JSON-based tools (package.json, tsconfig) and YAML-based tools (GitHub Actions, Docker Compose).

CSV

Converts a JSON array of objects to comma-separated values. Each object becomes a row; keys become column headers. Ready to open in Excel or Google Sheets.

XML

Converts JSON to a well-formed XML document. Useful when integrating with SOAP services or XML-based systems that consume structured data.

Escape / Unescape

Escape turns any raw text into a safe JSON string value (quotes, backslashes, and control characters are encoded). Unescape decodes it back. Handy when embedding code or HTML inside a JSON field.

Sort keys

Reorders all keys inside every object alphabetically (A→Z or Z→A), recursively through the entire tree. Useful for diffing configs or normalising output.

Understanding JSON validation errors

The most common JSON syntax mistakes and how this tool pinpoints them:

  • Trailing comma

    {"a": 1,}

    JSON does not allow a comma after the last item in an object or array. Remove the comma before } or ].

  • Single-quoted strings

    {"key": 'value'}

    JSON requires double quotes (") for all string values and keys. Replace single quotes with double quotes.

  • Unquoted keys

    {key: "value"}

    Unlike JavaScript objects, JSON requires keys to be double-quoted strings: {"key": "value"}.

  • Comments in JSON

    {"a": 1 // comment}

    Standard JSON (RFC 8259) does not support comments. Remove them, or switch to JSON5 / JSONC if your parser supports it.

  • Undefined or NaN values

    {"x": undefined}

    JSON has no undefined, NaN, or Infinity. Replace with null or a valid number string.

JSON parsing edge cases worth knowing

A few behaviors surprise developers even when the JSON itself is valid:

  • Duplicate keys

    {"a": 1, "a": 2} is valid JSON per RFC 8259, the spec does not forbid repeated keys. In practice every mainstream parser, including the JavaScript engine this tool runs on, keeps the last value and silently drops the earlier one. If a payload looks shorter after formatting than you expected, check for a repeated key.

  • Large integers lose precision

    JavaScript numbers are IEEE 754 doubles, which only represent integers exactly up to 2^53-1 (9007199254740991). A JSON number like a Snowflake ID or a 64-bit database key that exceeds that range can come out changed after formatting, since parsing round-trips through a JS number. If exact precision matters, keep IDs as JSON strings instead of raw numbers.

  • Key order is preserved, not guaranteed

    The JSON spec treats objects as unordered key/value sets. This tool, like virtually every modern JS engine, preserves insertion order in practice, so Beautify and Minify will not reshuffle your keys. Sort keys is a separate, explicit action, nothing reorders your object unless you ask for it.

  • Unicode escapes

    Characters outside the Basic Multilingual Plane (many emoji, some CJK extension characters) are encoded in JSON as a surrogate pair, e.g. "😀" for a face emoji. Beautify and Minify leave these escapes as-is rather than converting them to literal characters, since re-encoding is only cosmetic and both forms are equally valid JSON.

These behaviors follow RFC 8259, the official JSON data interchange format specification. The integer precision limit comes from JavaScript's Number.MAX_SAFE_INTEGER.

Frequently Asked Questions

What does the JSON formatter do?▾
The JSON formatter parses your JSON and re-serializes it with your chosen indentation (2 spaces, 4 spaces, or a tab character), making nested objects and arrays easy to read. It validates your JSON in the process, if the input is invalid, the error shows the exact line number and column so you can jump straight to the problem.
What is the difference between Beautify and Minify?▾
Beautify (Format) adds newlines and spaces to make JSON human-readable. Minify does the opposite, it strips all unnecessary whitespace to produce the smallest valid JSON string, which is useful for API payloads, cookies, or reducing file size in production.
How do I validate JSON and see the exact error location?▾
Just paste your JSON, validation is instant and reactive. If the JSON is invalid, the header bar above the input turns red and shows the specific error with line number and column (e.g. "Unexpected token }, line 4, col 3"). No button click needed. This makes it faster than tools that require you to click Validate.
Is my JSON data sent to a server?▾
No. All formatting, minifying, sorting, validating, and conversion runs entirely in your browser using the built-in JavaScript JSON engine. Your data never leaves your device, there are no API calls, no server logs, and no analytics on the content of your JSON.
How do I sort JSON keys alphabetically?▾
With valid JSON in the input, select A→Z or Z→A with the direction toggle, then click "Sort keys". The tool recursively reorders every object's keys at every depth. The sorted result replaces your input so you can continue editing or copy it out.
What JSON conversion formats are supported?▾
The tool converts JSON to YAML, CSV, and XML. CSV conversion requires the input to be a JSON array of objects (each object becomes a row). YAML and XML work on any valid JSON. Use the Escape mode to turn any text into a safe JSON string value, and Unescape to decode it back.
What is JSON escaping and when do I need it?▾
JSON string values must escape certain characters: double quotes become \", backslashes become \\, newlines become \n, and so on. Use the Escape mode when you need to embed a block of text (code, HTML, a file path) as a JSON string value. Use Unescape to decode a previously escaped string back to readable text.
What JSON is supported?▾
Standard JSON as defined by RFC 8259: quoted string keys, and values of type string, number, boolean, null, object, or array. Comments and trailing commas (common in JSON5 or JSONC) are not supported by the standard parser and will produce a validation error. Large files up to several megabytes work fine, there is no artificial size limit.
What happens to duplicate keys in a JSON object?▾
RFC 8259 does not forbid repeated keys in an object, so {"a": 1, "a": 2} is technically valid JSON. This tool, like every mainstream JSON parser, keeps the last value for a repeated key and drops the earlier one during formatting. If your output has fewer fields than expected, check the input for a duplicated key.
Why did a large number change after I formatted my JSON?▾
JSON is parsed into JavaScript numbers, which are IEEE 754 doubles and only represent integers exactly up to 2^53-1 (9007199254740991). A 64-bit ID or Snowflake ID beyond that range can lose precision when round-tripped through the formatter. If you need to preserve an exact large integer, store it as a JSON string instead of a raw number.

By Toolember · Updated September 2026