JSON Formatter
Validate, format and minify JSON locally.
📐 工作原理与说明
JSON 格式化按语法树递归输出:解析器先做词法分析(识别字符串、数字、true/false/null 与括号),再按层级缩进(每层 2 空格或制表符);压缩即移除全部结构空白仅保留分隔符;校验失败时报出错误行列位置,字符串内转义序列须成对且不可跨行。
Formula & Standard References
| Item | Formula | Source / Standard |
|---|---|---|
| JSON syntax | { } [ ] string/number/bool/null | ECMA-404 / RFC 8259 |
| Indentation | 2 spaces / 4 spaces / tab | JSON.stringify(.,null,n) |
| Validation | Parse failure returns error position | RFC 8259 §8 |
📌 使用说明
- 格式化:自动校验 JSON 并以 2 空格缩进展示。
- 压缩:去除多余空白,生成单行 JSON。
- 若 JSON 不合法,将高亮显示错误位置与原因。