跳至主要内容
搜索工具
主题

仅保存在此设备上。

中文
在线工具

JSON Formatter

v1.0.0 100% Local

Free online JSON formatter, validator, and minifier. Format, validate, minify, repair, flatten, and inspect JSON locally in your browser. No data is sent to any s...

抢先评分 免费 — 在您的浏览器中运行 Productivity

Added Maintained by Parsepad

JSON Formatter

实时工作区

MERGE | 0 files | Auto-detect | Ready
[--:--:--] INFO Console ready. Run the tool to see activity.

Paste input above and ask a question, or use a quick action.

On this page
指南

About JSON Formatter

Format, validate, minify, repair, flatten, and inspect JSON entirely in your browser. No data leaves your device — all processing runs locally using native browser APIs.

Features

Format

Pretty-print JSON with your choice of indentation: 2 spaces, 4 spaces, or tab. Enable the Sort Keys toggle to recursively sort all object keys alphabetically, making large structures easier to compare or diff.

Minify

Strip all whitespace from JSON to produce compact output. Useful for reducing payload size, copying into config files, or comparing two structures after normalization.

Validate

Check whether input is valid JSON without modifying it. On failure, the status bar shows the exact error message along with the estimated line and column number where parsing stopped.

Repair

Apply best-effort fixes for common issues that appear in copy-pasted JSON:

  • Strip UTF-8 BOM characters
  • Remove JavaScript // line comments and /* */ block comments
  • Remove trailing commas before } or ]

Repair always reports whether it changed the input. It will not silently alter JSON during other actions — you must invoke it explicitly.

Flatten

Expand a nested JSON structure into a flat array of { path, value } rows using dot notation for object keys and bracket notation for array indices:

  • Object key path: user.address.city
  • Array item path: items[0].id

Use the Path filter input to show only paths that contain a given substring. For example, entering address returns only rows whose path includes the word address.

Extract Keys

Scan all objects in the JSON (including nested and inside arrays) and return each unique key name with the number of times it appears. Useful for understanding schema coverage in an array of heterogeneous objects.

Inspect

Return a structural summary of the JSON:

MetricDescription
CharactersTotal character count of the input
ObjectsTotal number of object nodes
ArraysTotal number of array nodes
KeysTotal number of object key occurrences
PrimitivesTotal number of string, number, boolean, and null values
Max DepthMaximum nesting level

Settings

SettingOptionsDefault
Indent2 spaces, 4 spaces, Tab2 spaces
Sort KeysOn / OffOff
Path FilterAny text(empty)

Settings apply to the next action you run. Change them any time before pressing a button.

Keyboard Shortcuts

ShortcutAction
Ctrl+Enter or Cmd+EnterFormat
Ctrl+Shift+M or Cmd+Shift+MMinify

Inspector Cards

The row of stat cards below the editor updates automatically after each action. It shows the validity status, input size, and structural counts for the last processed JSON.

Privacy

All processing runs locally in your browser using the native JSON.parse and JSON.stringify APIs. No JSON input, no output fragments, and no metadata are transmitted to any server. This tool works fully offline once the page has loaded.

FAQ

Why does Validate fail but Repair succeeds? Repair strips comments and trailing commas before parsing. If those were the only problems, the repaired string will be valid. Repair cannot fix structural errors such as mismatched brackets or unquoted keys.

Does Sort Keys affect array element order? No. Sort Keys only reorders object property keys. The order of elements within arrays is preserved exactly.

What does the Path Filter do in Flatten? It filters the output rows to those whose path string contains the filter text. It is a simple substring match, not a glob or regex. Leave it blank to see all paths.

Can I use this on large JSON files? Yes — paste content directly into the input area. Recursion depth is capped at 200 levels to prevent stack overflows on pathologically deep structures. Very large inputs (tens of megabytes) may take a moment to process depending on your device.

What counts as a key in the inspector? Each object property occurrence counts as one key. If you have 100 objects each with an id property, Keys will show 100, and Extract Keys will show { "id": 100 }.