JSON Formatter

Format, validate, and beautify JSON data with intelligent indentation and syntax highlighting

Runs locally

JSON Input

Formatted Output

0 bytes

Inspector

Paste valid JSON — structure, tree and key paths appear here automatically

Advanced Options

Compare with another JSON

Send this JSON to Data Diff and paste a second version to see what changed.

Validation results you can act on

Validation runs on every keystroke. When the JSON is valid you get live counts of objects, arrays, keys and depth. When it is not, the error is reported with its exact line and column, the probable cause, and a highlight at the failing position in the editor — not just "Invalid JSON".

Common JSON errors this tool pinpoints

These four mistakes account for most invalid JSON. Each one is detected with a position and a probable cause:

Trailing comma

A comma before a closing } or ] . Reported as "unexpected token" at the next line — the cause message points back to the comma.

Missing or unmatched quote

An unterminated string swallows the rest of the document. The parser reports an unexpected token far from the real mistake; the line/column highlight shows where to look.

Unexpected token

Single quotes instead of double quotes, comments, or unquoted keys. Standard JSON (RFC 8259) requires double quotes for all strings and keys.

Invalid escape sequence

Only \" \ \/ \b \f \n \r \t and \uXXXX are valid escapes. A lone backslash produces an error at the exact position of the invalid sequence.

Before / After

Minified API response on the left, the same data formatted with 2-space indent on the right. Structure, tree and paths update from the parsed document.

Before
{"user":{"id":123,"name":"Chen","roles":["admin","editor"],"active":true}}
After
{
  "user": {
    "id": 123,
    "name": "Chen",
    "roles": [
      "admin",
      "editor"
    ],
    "active": true
  }
}

JSON standard quick reference (RFC 8259)

  • Two structures: an object (unordered name/value pairs, {}) and an array (ordered values, []).
  • A value is a string in double quotes, a number, true, false, null, an object, or an array.
  • Numbers never have leading zeros; 1E10 and 0.5e-2 exponent forms are allowed.
  • Strings may not contain literal control characters — they must be escaped (\n, \t, \uXXXX).
  • No comments, no trailing commas, no single quotes — the strict grammar is what makes JSON portable.

Next steps with this data

Formatting is the first step. Continue the workflow without leaving your browser:

Frequently Asked Questions

Common questions about Json Formatter formatting answered

Yes, our JSON formatter is completely free with no registration required. All processing happens in your browser.

Simply paste your JSON data into the editor and click Validate. The tool will instantly check syntax, report errors with line numbers, and display object/array/property counts.

JSON minification removes all unnecessary whitespace to reduce file size. Use it before deploying JSON to production to save bandwidth and improve load times.

Yes, the formatter supports files up to 10MB with optimized parsing algorithms. Large API responses, database exports, and configuration files are handled efficiently.

The formatter follows strict RFC 8259 JSON specification. For JSON with trailing commas or comments, validation will report those as errors since they are not valid standard JSON.

Escapes like \u00e9 are decoded for display, and non-ASCII text is preserved verbatim rather than re-escaped. Sorting a mixed array of numbers and strings follows stable sort semantics (equal keys keep their original order), matching how modern engines implement Array.prototype.sort per ECMA-262.

Yes. Enable key sorting in the options panel to reorder object properties alphabetically at every nesting level. Sorting makes configuration files and API fixtures easier to diff in version control, because unrelated insertions no longer scatter changes across the file.

JSON itself has no integer size limit, but JavaScript's Number type stores only 53 safe integer bits. Values beyond 9,007,199,254,740,991 (2^53 - 1) or high-precision decimals get rounded. This is a JavaScript engine constraint documented in ECMA-262, not a bug in the formatter - treat such values as strings in your API design.

{-- * External Resources Component(#19 Phase 3b 内容佐证工程) * 工具页「权威引用」区块:RFC / W3C / WHATWG / ECMA / IANA / 官方规范站 / 官方语言文档 / Wikipedia。 * * - 接受 :slug 属性 → 经 config/tool-sources.php 家族矩阵渲染该工具的权威引用 * - slug 未命中映射时不渲染(无权威来源的工具静默跳过) * - 链接 title 保持英文(引用源专名);description 经 * common.resources.descriptions.{key} 本地化,lang 未命中回退英文(线上不裸奔) * - 链接保持 dofollow(rel="noopener noreferrer") * * @param string|null $slug --}}

Related Tools