JSON 压缩

去除空白以压缩 JSON

Loading editor...

Shrink JSON before it crosses the wire

Whitespace and indentation are great for humans but pure overhead for the network. Minifying JSON strips them out, often cutting payload size by 30-60%, so API responses, config files, and embedded data load faster without changing any of the actual data your code consumes.

Use the minifier when you need to

Reduce API response size

Strip indentation from JSON before serving it to clients to save bandwidth and reduce time-to-first-byte.

Embed JSON in HTML or strings

Compact JSON before injecting it into a script tag, environment variable, or single-line config value.

Compare actual payload size

Minify both versions of a payload to measure the structural difference without indentation noise.

How to minify JSON quickly

  1. 1

    Paste the formatted JSON into the editor.

  2. 2

    Click Minify to remove all whitespace, indentation, and line breaks.

  3. 3

    Copy the result or download it for use in production payloads.

Common minifier workflows

Trim API response payloads

Send JSON without indentation in production while keeping pretty-printed copies for debugging.

Inline configuration in build outputs

Embed JSON config inside JavaScript bundles or HTML templates without expanding bundle size.

Prepare data for storage size limits

Squeeze a payload under DynamoDB, Redis, or column-size limits without restructuring the data.

相关工具

常见问题

Minify 会移除 JSON 里不必要的空白、缩进和换行。数据内容完全不变,只是去掉格式字符,从而减小体积。对常见 JSON 来说,通常能减少 30-60% 的大小。

在网络传输或生产环境使用前压缩更合适,比如 API 响应、生产配置文件、存储数据等。payload 更小意味着传输更快、带宽成本更低。需要给人阅读的 JSON 不建议压缩。

取决于缩进和嵌套深度。2 空格缩进且嵌套很深的文件,可能缩小 40-60%;结构很平、值很短的数组,可能只缩小 10-15%。可以用我们的 Size Analyzer 查看精确差异。

不会。Minify 只移除格式化空白,所有 key、value、数组和嵌套结构都保持不变。对格式化版和压缩版分别执行 JSON.parse(),结果是完全一致的。