Skip to content
DevTools

JSON Formatter, Validator, Viewer & Repair Online

Format, validate, minify, repair, sort and explore JSON in one place. Exact error line and column, a collapsible tree view and size stats. Free and private.

Input

Output

Ready

Runs locally in your browser — your data is never uploaded.

About the JSON Formatter & Validator

Format, validate, minify, repair, sort and explore JSON in one workspace. Paste a document once and switch between actions with the toolbar — no copying between separate tools.

Invalid JSON is reported with the exact line and column of the problem, and the output can be viewed as indented code or as a collapsible, searchable tree.

How to use it

  1. Paste JSON, upload a .json file or drag one in.
  2. Pick an action: Format, Validate, Minify, Repair, Sort keys, Flatten or Unflatten.
  3. Switch the output between Code and Tree, then copy or download the result.

Features

  • Instant formatting with 2/4-space or tab indentation
  • Strict RFC 8259 validation with exact error line and column
  • Tree view with search, item counts and click-to-copy JSONPath
  • Lossless minification with before/after size
  • Repairs single quotes, unquoted keys, comments, trailing commas and Python literals
  • Recursive key sorting with five orders and pinned keys
  • Flatten to dot-notation paths and back
  • Handles multi-megabyte files

What each action does

Format & beautify

Turns messy, minified or one-line JSON into clean, indented output. Only whitespace changes — keys, values and order stay the same.

Validate JSON

Checks the text against RFC 8259 and reports the line and column of the first syntax error. Valid documents get a structural summary: root type, number of objects, arrays and keys, maximum nesting depth and size.

Useful for debugging API payloads, configuration files and webhook bodies before they reach your code.

View as a tree

Explore JSON as an interactive tree instead of scrolling through text. Expand and collapse nodes, see item counts at a glance and search keys and values.

Click any key to copy its JSONPath (for example $.projects[1].title), ready for code, jq filters or test assertions.

Minify JSON

Removes all unnecessary whitespace and line breaks to make payloads smaller — handy for API responses, embedding JSON in HTML or environment variables. The status bar shows the size before and after.

Repair broken JSON

Converts JavaScript object literals and Python dictionaries into strict JSON: single quotes become double quotes, unquoted keys are quoted, comments and trailing commas are removed, True/False/None become true/false/null and missing commas are added. The result is validated and formatted.

Sort keys

Sorts object keys A–Z, Z–A, case-insensitively, by length, or with primitive values before nested objects — recursively or on the top level only. Pin keys such as id or name to the top. Array order is never changed, because it is meaningful.

Flatten and unflatten

Flatten turns nested JSON into a single level of dot-notation paths such as user.roles[0], which is easy to diff, grep or load into a spreadsheet. Unflatten rebuilds the nested structure from those paths.

Frequently asked questions

What is a JSON formatter?

A JSON formatter (or beautifier) adds consistent indentation and line breaks to JSON so humans can read it. It doesn't change the data — only the whitespace.

What makes JSON invalid?

Trailing commas, single-quoted strings, unquoted keys, comments, undefined, NaN and unescaped control characters in strings are the most common problems. JSON is stricter than JavaScript object syntax. The Repair action fixes most of these automatically.

Does it validate against a JSON Schema?

This tool checks syntax. To describe the expected structure, generate a schema with the JSON Schema Generator.

What is JSONPath?

JSONPath is a query syntax for JSON, similar to XPath for XML. $ is the root, .key selects a property and [n] selects an array element. Click any key in the tree view to copy its path.

Does minifying change my data?

No. Only whitespace outside strings is removed; keys, values and order stay the same. With gzip or brotli compression the network saving is usually smaller than the raw size difference.

Can it fix every broken JSON?

It fixes the most common problems automatically. Severely truncated documents (for example, missing closing brackets) still need a manual edit — the error message tells you where.

Why sort JSON keys?

Sorted keys make version-control diffs smaller and documents easier to compare, and give stable output for snapshots and caches. Object key order has no meaning in JSON, so sorting never changes the data.

Can I format very large JSON files?

Yes. Formatting uses the browser's native JSON parser, which handles files of several megabytes in milliseconds. Collapse top-level nodes in the tree view to keep very large documents responsive.

Can I link straight to an action?

Yes. Add ?action=validate, minify, repair, sort, flatten or unflatten — or ?view=tree — to the URL. The address bar updates as you switch, so you can bookmark or share the exact setup.

Is my data uploaded anywhere?

No. All processing happens in JavaScript inside your browser tab. Your input is never sent to a server, logged or stored, so it is safe to use with internal or sensitive data.