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 不合法,將高亮顯示錯誤位置與原因。