[{"data":1,"prerenderedAt":807},["ShallowReactive",2],{"post-/blog/how-to-format-json":3,"related-/blog/how-to-format-json":189},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"date":10,"category":11,"keywords":12,"body":16,"_type":183,"_id":184,"_source":185,"_file":186,"_stem":187,"_extension":188},"/blog/how-to-format-json","blog",false,"","如何格式化 JSON：美化与缩进","JSON 格式化（美化）是为 JSON 添加缩进与换行，提升可读性。本文介绍在线格式化方法。","2026-08-19","工具",[13,14,15],"json格式化","json美化","format json",{"type":17,"children":18,"toc":175},"root",[19,27,33,39,44,49,54,59,132,137,159,164,169],{"type":20,"tag":21,"props":22,"children":24},"element","h1",{"id":23},"如何格式化-json美化与缩进",[25],{"type":26,"value":8},"text",{"type":20,"tag":28,"props":29,"children":30},"p",{},[31],{"type":26,"value":32},"JSON 格式化又称美化（beautify）或 pretty print，指为压缩的 JSON 添加缩进与换行，使其结构清晰易读。",{"type":20,"tag":34,"props":35,"children":37},"h2",{"id":36},"为什么格式化",[38],{"type":26,"value":36},{"type":20,"tag":28,"props":40,"children":41},{},[42],{"type":26,"value":43},"压缩 JSON 单行难读，格式化后层级清晰，便于调试与排查错误。",{"type":20,"tag":34,"props":45,"children":47},{"id":46},"如何操作",[48],{"type":26,"value":46},{"type":20,"tag":28,"props":50,"children":51},{},[52],{"type":26,"value":53},"粘贴 JSON 到格式化工具，选择缩进（2/4 空格或 Tab），一键生成美化结果。",{"type":20,"tag":34,"props":55,"children":57},{"id":56},"代码示例",[58],{"type":26,"value":56},{"type":20,"tag":60,"props":61,"children":65},"pre",{"className":62,"code":63,"language":64,"meta":7,"style":7},"language-json shiki shiki-themes github-dark","{\"a\":1,\"b\":{\"c\":2}}\n","json",[66],{"type":20,"tag":67,"props":68,"children":69},"code",{"__ignoreMap":7},[70],{"type":20,"tag":71,"props":72,"children":75},"span",{"class":73,"line":74},"line",1,[76,82,88,93,98,103,108,113,118,122,127],{"type":20,"tag":71,"props":77,"children":79},{"style":78},"--shiki-default:#E1E4E8",[80],{"type":26,"value":81},"{",{"type":20,"tag":71,"props":83,"children":85},{"style":84},"--shiki-default:#79B8FF",[86],{"type":26,"value":87},"\"a\"",{"type":20,"tag":71,"props":89,"children":90},{"style":78},[91],{"type":26,"value":92},":",{"type":20,"tag":71,"props":94,"children":95},{"style":84},[96],{"type":26,"value":97},"1",{"type":20,"tag":71,"props":99,"children":100},{"style":78},[101],{"type":26,"value":102},",",{"type":20,"tag":71,"props":104,"children":105},{"style":84},[106],{"type":26,"value":107},"\"b\"",{"type":20,"tag":71,"props":109,"children":110},{"style":78},[111],{"type":26,"value":112},":{",{"type":20,"tag":71,"props":114,"children":115},{"style":84},[116],{"type":26,"value":117},"\"c\"",{"type":20,"tag":71,"props":119,"children":120},{"style":78},[121],{"type":26,"value":92},{"type":20,"tag":71,"props":123,"children":124},{"style":84},[125],{"type":26,"value":126},"2",{"type":20,"tag":71,"props":128,"children":129},{"style":78},[130],{"type":26,"value":131},"}}\n",{"type":20,"tag":34,"props":133,"children":135},{"id":134},"推荐在线工具",[136],{"type":26,"value":134},{"type":20,"tag":138,"props":139,"children":140},"ul",{},[141,151],{"type":20,"tag":142,"props":143,"children":144},"li",{},[145],{"type":20,"tag":146,"props":147,"children":149},"a",{"href":148},"/format",[150],{"type":26,"value":148},{"type":20,"tag":142,"props":152,"children":153},{},[154],{"type":20,"tag":146,"props":155,"children":157},{"href":156},"/minify",[158],{"type":26,"value":156},{"type":20,"tag":34,"props":160,"children":162},{"id":161},"小结",[163],{"type":26,"value":161},{"type":20,"tag":28,"props":165,"children":166},{},[167],{"type":26,"value":168},"JSON 格式化（美化）是为 JSON 添加缩进与换行，提升可读性。本文介绍在线格式化方法。 JSONDog 提供全套 JSON 在线工具，纯前端、零上传、中英双语，欢迎免费使用。",{"type":20,"tag":170,"props":171,"children":172},"style",{},[173],{"type":26,"value":174},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"title":7,"searchDepth":176,"depth":176,"links":177},2,[178,179,180,181,182],{"id":36,"depth":176,"text":36},{"id":46,"depth":176,"text":46},{"id":56,"depth":176,"text":56},{"id":134,"depth":176,"text":134},{"id":161,"depth":176,"text":161},"markdown","content:blog:how-to-format-json.md","content","blog/how-to-format-json.md","blog/how-to-format-json","md",[190,361,480,649],{"_path":191,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":192,"description":193,"date":10,"category":11,"keywords":194,"body":198,"_type":183,"_id":358,"_source":185,"_file":359,"_stem":360,"_extension":188},"/blog/how-to-minify-json","如何压缩 JSON：Minify","JSON 压缩去除所有空白与换行，减小体积，用于生产环境传输。",[195,196,197],"json压缩","json minify","compress json",{"type":17,"children":199,"toc":351},[200,205,210,215,220,225,230,234,317,321,338,342,347],{"type":20,"tag":21,"props":201,"children":203},{"id":202},"如何压缩-jsonminify",[204],{"type":26,"value":192},{"type":20,"tag":28,"props":206,"children":207},{},[208],{"type":26,"value":209},"JSON 压缩（minify）去除所有不必要的空白、换行与缩进，将 JSON 压成单行，减小传输体积。",{"type":20,"tag":34,"props":211,"children":213},{"id":212},"压缩好处",[214],{"type":26,"value":212},{"type":20,"tag":28,"props":216,"children":217},{},[218],{"type":26,"value":219},"减小文件体积，加快网络传输，节省存储空间，适合生产环境。",{"type":20,"tag":34,"props":221,"children":223},{"id":222},"开发建议",[224],{"type":26,"value":222},{"type":20,"tag":28,"props":226,"children":227},{},[228],{"type":26,"value":229},"开发时用格式化便于阅读，部署时用压缩优化性能。",{"type":20,"tag":34,"props":231,"children":232},{"id":56},[233],{"type":26,"value":56},{"type":20,"tag":60,"props":235,"children":237},{"className":62,"code":236,"language":64,"meta":7,"style":7},"{\"a\":1,\"b\":[2,3],\"c\":{\"d\":4}}\n",[238],{"type":20,"tag":67,"props":239,"children":240},{"__ignoreMap":7},[241],{"type":20,"tag":71,"props":242,"children":243},{"class":73,"line":74},[244,248,252,256,260,264,268,273,277,281,286,291,295,299,304,308,313],{"type":20,"tag":71,"props":245,"children":246},{"style":78},[247],{"type":26,"value":81},{"type":20,"tag":71,"props":249,"children":250},{"style":84},[251],{"type":26,"value":87},{"type":20,"tag":71,"props":253,"children":254},{"style":78},[255],{"type":26,"value":92},{"type":20,"tag":71,"props":257,"children":258},{"style":84},[259],{"type":26,"value":97},{"type":20,"tag":71,"props":261,"children":262},{"style":78},[263],{"type":26,"value":102},{"type":20,"tag":71,"props":265,"children":266},{"style":84},[267],{"type":26,"value":107},{"type":20,"tag":71,"props":269,"children":270},{"style":78},[271],{"type":26,"value":272},":[",{"type":20,"tag":71,"props":274,"children":275},{"style":84},[276],{"type":26,"value":126},{"type":20,"tag":71,"props":278,"children":279},{"style":78},[280],{"type":26,"value":102},{"type":20,"tag":71,"props":282,"children":283},{"style":84},[284],{"type":26,"value":285},"3",{"type":20,"tag":71,"props":287,"children":288},{"style":78},[289],{"type":26,"value":290},"],",{"type":20,"tag":71,"props":292,"children":293},{"style":84},[294],{"type":26,"value":117},{"type":20,"tag":71,"props":296,"children":297},{"style":78},[298],{"type":26,"value":112},{"type":20,"tag":71,"props":300,"children":301},{"style":84},[302],{"type":26,"value":303},"\"d\"",{"type":20,"tag":71,"props":305,"children":306},{"style":78},[307],{"type":26,"value":92},{"type":20,"tag":71,"props":309,"children":310},{"style":84},[311],{"type":26,"value":312},"4",{"type":20,"tag":71,"props":314,"children":315},{"style":78},[316],{"type":26,"value":131},{"type":20,"tag":34,"props":318,"children":319},{"id":134},[320],{"type":26,"value":134},{"type":20,"tag":138,"props":322,"children":323},{},[324,331],{"type":20,"tag":142,"props":325,"children":326},{},[327],{"type":20,"tag":146,"props":328,"children":329},{"href":156},[330],{"type":26,"value":156},{"type":20,"tag":142,"props":332,"children":333},{},[334],{"type":20,"tag":146,"props":335,"children":336},{"href":148},[337],{"type":26,"value":148},{"type":20,"tag":34,"props":339,"children":340},{"id":161},[341],{"type":26,"value":161},{"type":20,"tag":28,"props":343,"children":344},{},[345],{"type":26,"value":346},"JSON 压缩去除所有空白与换行，减小体积，用于生产环境传输。 JSONDog 提供全套 JSON 在线工具，纯前端、零上传、中英双语，欢迎免费使用。",{"type":20,"tag":170,"props":348,"children":349},{},[350],{"type":26,"value":174},{"title":7,"searchDepth":176,"depth":176,"links":352},[353,354,355,356,357],{"id":212,"depth":176,"text":212},{"id":222,"depth":176,"text":222},{"id":56,"depth":176,"text":56},{"id":134,"depth":176,"text":134},{"id":161,"depth":176,"text":161},"content:blog:how-to-minify-json.md","blog/how-to-minify-json.md","blog/how-to-minify-json",{"_path":362,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":363,"description":364,"date":10,"category":11,"keywords":365,"body":369,"_type":183,"_id":477,"_source":185,"_file":478,"_stem":479,"_extension":188},"/blog/how-to-validate-json","如何校验 JSON 语法","JSON 校验检查语法是否合法，定位错误行号并给出修复建议。",[366,367,368],"json校验","json验证","validate json",{"type":17,"children":370,"toc":470},[371,376,381,386,391,396,401,405,435,439,457,461,466],{"type":20,"tag":21,"props":372,"children":374},{"id":373},"如何校验-json-语法",[375],{"type":26,"value":363},{"type":20,"tag":28,"props":377,"children":378},{},[379],{"type":26,"value":380},"JSON 校验用于检查 JSON 文本是否符合语法规范，发现错误并定位到具体行列。",{"type":20,"tag":34,"props":382,"children":384},{"id":383},"常见错误",[385],{"type":26,"value":383},{"type":20,"tag":28,"props":387,"children":388},{},[389],{"type":26,"value":390},"单引号、尾逗号、缺引号、缺逗号是高频错误，校验工具会指出位置与原因。",{"type":20,"tag":34,"props":392,"children":394},{"id":393},"校验工具",[395],{"type":26,"value":393},{"type":20,"tag":28,"props":397,"children":398},{},[399],{"type":26,"value":400},"粘贴 JSON 即时校验，合法显示美化预览，非法显示错误行号与修复建议。",{"type":20,"tag":34,"props":402,"children":403},{"id":56},[404],{"type":26,"value":56},{"type":20,"tag":60,"props":406,"children":408},{"className":62,"code":407,"language":64,"meta":7,"style":7},"{\"bad\": \"missing quote}\n",[409],{"type":20,"tag":67,"props":410,"children":411},{"__ignoreMap":7},[412],{"type":20,"tag":71,"props":413,"children":414},{"class":73,"line":74},[415,419,424,429],{"type":20,"tag":71,"props":416,"children":417},{"style":78},[418],{"type":26,"value":81},{"type":20,"tag":71,"props":420,"children":421},{"style":84},[422],{"type":26,"value":423},"\"bad\"",{"type":20,"tag":71,"props":425,"children":426},{"style":78},[427],{"type":26,"value":428},": ",{"type":20,"tag":71,"props":430,"children":432},{"style":431},"--shiki-default:#9ECBFF",[433],{"type":26,"value":434},"\"missing quote}\n",{"type":20,"tag":34,"props":436,"children":437},{"id":134},[438],{"type":26,"value":134},{"type":20,"tag":138,"props":440,"children":441},{},[442,450],{"type":20,"tag":142,"props":443,"children":444},{},[445],{"type":20,"tag":146,"props":446,"children":448},{"href":447},"/validate",[449],{"type":26,"value":447},{"type":20,"tag":142,"props":451,"children":452},{},[453],{"type":20,"tag":146,"props":454,"children":455},{"href":148},[456],{"type":26,"value":148},{"type":20,"tag":34,"props":458,"children":459},{"id":161},[460],{"type":26,"value":161},{"type":20,"tag":28,"props":462,"children":463},{},[464],{"type":26,"value":465},"JSON 校验检查语法是否合法，定位错误行号并给出修复建议。 JSONDog 提供全套 JSON 在线工具，纯前端、零上传、中英双语，欢迎免费使用。",{"type":20,"tag":170,"props":467,"children":468},{},[469],{"type":26,"value":174},{"title":7,"searchDepth":176,"depth":176,"links":471},[472,473,474,475,476],{"id":383,"depth":176,"text":383},{"id":393,"depth":176,"text":393},{"id":56,"depth":176,"text":56},{"id":134,"depth":176,"text":134},{"id":161,"depth":176,"text":161},"content:blog:how-to-validate-json.md","blog/how-to-validate-json.md","blog/how-to-validate-json",{"_path":481,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":482,"description":483,"date":10,"category":11,"keywords":484,"body":488,"_type":183,"_id":646,"_source":185,"_file":647,"_stem":648,"_extension":188},"/blog/json-diff-compare","JSON 对比与差异分析","JSON 对比工具递归比较两段 JSON，输出新增、删除、修改的节点路径。",[485,486,487],"json对比","json diff","json compare",{"type":17,"children":489,"toc":639},[490,495,500,505,510,515,520,524,604,608,626,630,635],{"type":20,"tag":21,"props":491,"children":493},{"id":492},"json-对比与差异分析",[494],{"type":26,"value":482},{"type":20,"tag":28,"props":496,"children":497},{},[498],{"type":26,"value":499},"JSON 对比工具递归比较两段 JSON 的差异，输出每个新增、删除、修改节点的路径，便于排查变更。",{"type":20,"tag":34,"props":501,"children":503},{"id":502},"对比规则",[504],{"type":26,"value":502},{"type":20,"tag":28,"props":506,"children":507},{},[508],{"type":26,"value":509},"对象按键名比较不区分顺序，数组按索引比较，基本值按相等比较。",{"type":20,"tag":34,"props":511,"children":513},{"id":512},"使用场景",[514],{"type":26,"value":512},{"type":20,"tag":28,"props":516,"children":517},{},[518],{"type":26,"value":519},"对比 API 两次返回、排查配置变更、版本差异分析。",{"type":20,"tag":34,"props":521,"children":522},{"id":56},[523],{"type":26,"value":56},{"type":20,"tag":60,"props":525,"children":527},{"className":62,"code":526,"language":64,"meta":7,"style":7},"{\"a\":1,\"b\":2} vs {\"a\":1,\"c\":3}\n",[528],{"type":20,"tag":67,"props":529,"children":530},{"__ignoreMap":7},[531],{"type":20,"tag":71,"props":532,"children":533},{"class":73,"line":74},[534,538,542,546,550,554,558,562,566,571,575,579,583,587,591,595,599],{"type":20,"tag":71,"props":535,"children":536},{"style":78},[537],{"type":26,"value":81},{"type":20,"tag":71,"props":539,"children":540},{"style":84},[541],{"type":26,"value":87},{"type":20,"tag":71,"props":543,"children":544},{"style":78},[545],{"type":26,"value":92},{"type":20,"tag":71,"props":547,"children":548},{"style":84},[549],{"type":26,"value":97},{"type":20,"tag":71,"props":551,"children":552},{"style":78},[553],{"type":26,"value":102},{"type":20,"tag":71,"props":555,"children":556},{"style":84},[557],{"type":26,"value":107},{"type":20,"tag":71,"props":559,"children":560},{"style":78},[561],{"type":26,"value":92},{"type":20,"tag":71,"props":563,"children":564},{"style":84},[565],{"type":26,"value":126},{"type":20,"tag":71,"props":567,"children":568},{"style":78},[569],{"type":26,"value":570},"} vs {",{"type":20,"tag":71,"props":572,"children":573},{"style":84},[574],{"type":26,"value":87},{"type":20,"tag":71,"props":576,"children":577},{"style":78},[578],{"type":26,"value":92},{"type":20,"tag":71,"props":580,"children":581},{"style":84},[582],{"type":26,"value":97},{"type":20,"tag":71,"props":584,"children":585},{"style":78},[586],{"type":26,"value":102},{"type":20,"tag":71,"props":588,"children":589},{"style":84},[590],{"type":26,"value":117},{"type":20,"tag":71,"props":592,"children":593},{"style":78},[594],{"type":26,"value":92},{"type":20,"tag":71,"props":596,"children":597},{"style":84},[598],{"type":26,"value":285},{"type":20,"tag":71,"props":600,"children":601},{"style":78},[602],{"type":26,"value":603},"}\n",{"type":20,"tag":34,"props":605,"children":606},{"id":134},[607],{"type":26,"value":134},{"type":20,"tag":138,"props":609,"children":610},{},[611,619],{"type":20,"tag":142,"props":612,"children":613},{},[614],{"type":20,"tag":146,"props":615,"children":617},{"href":616},"/diff",[618],{"type":26,"value":616},{"type":20,"tag":142,"props":620,"children":621},{},[622],{"type":20,"tag":146,"props":623,"children":624},{"href":148},[625],{"type":26,"value":148},{"type":20,"tag":34,"props":627,"children":628},{"id":161},[629],{"type":26,"value":161},{"type":20,"tag":28,"props":631,"children":632},{},[633],{"type":26,"value":634},"JSON 对比工具递归比较两段 JSON，输出新增、删除、修改的节点路径。 JSONDog 提供全套 JSON 在线工具，纯前端、零上传、中英双语，欢迎免费使用。",{"type":20,"tag":170,"props":636,"children":637},{},[638],{"type":26,"value":174},{"title":7,"searchDepth":176,"depth":176,"links":640},[641,642,643,644,645],{"id":502,"depth":176,"text":502},{"id":512,"depth":176,"text":512},{"id":56,"depth":176,"text":56},{"id":134,"depth":176,"text":134},{"id":161,"depth":176,"text":161},"content:blog:json-diff-compare.md","blog/json-diff-compare.md","blog/json-diff-compare",{"_path":650,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":651,"description":652,"date":10,"category":11,"keywords":653,"body":657,"_type":183,"_id":804,"_source":185,"_file":805,"_stem":806,"_extension":188},"/blog/json-editor-online","在线 JSON 编辑器推荐","在线 JSON 编辑器提供语法高亮、实时校验、行号，无需安装即可编辑 JSON。",[654,655,656],"json编辑器","json editor","在线编辑json",{"type":17,"children":658,"toc":797},[659,664,669,674,679,684,689,693,762,766,784,788,793],{"type":20,"tag":21,"props":660,"children":662},{"id":661},"在线-json-编辑器推荐",[663],{"type":26,"value":651},{"type":20,"tag":28,"props":665,"children":666},{},[667],{"type":26,"value":668},"在线 JSON 编辑器让你在浏览器中直接编辑 JSON，提供语法高亮、行号、实时校验，无需安装任何软件。",{"type":20,"tag":34,"props":670,"children":672},{"id":671},"编辑器功能",[673],{"type":26,"value":671},{"type":20,"tag":28,"props":675,"children":676},{},[677],{"type":26,"value":678},"语法高亮、实时校验、错误提示、复制下载，数据不出浏览器。",{"type":20,"tag":34,"props":680,"children":682},{"id":681},"相比本地",[683],{"type":26,"value":681},{"type":20,"tag":28,"props":685,"children":686},{},[687],{"type":26,"value":688},"无需安装、跨设备可用、即时上手，适合临时编辑与快速校验。",{"type":20,"tag":34,"props":690,"children":691},{"id":56},[692],{"type":26,"value":56},{"type":20,"tag":60,"props":694,"children":696},{"className":62,"code":695,"language":64,"meta":7,"style":7},"{\n  \"name\": \"JSONDog\",\n  \"tools\": [\"editor\"]\n}\n",[697],{"type":20,"tag":67,"props":698,"children":699},{"__ignoreMap":7},[700,708,730,754],{"type":20,"tag":71,"props":701,"children":702},{"class":73,"line":74},[703],{"type":20,"tag":71,"props":704,"children":705},{"style":78},[706],{"type":26,"value":707},"{\n",{"type":20,"tag":71,"props":709,"children":710},{"class":73,"line":176},[711,716,720,725],{"type":20,"tag":71,"props":712,"children":713},{"style":84},[714],{"type":26,"value":715},"  \"name\"",{"type":20,"tag":71,"props":717,"children":718},{"style":78},[719],{"type":26,"value":428},{"type":20,"tag":71,"props":721,"children":722},{"style":431},[723],{"type":26,"value":724},"\"JSONDog\"",{"type":20,"tag":71,"props":726,"children":727},{"style":78},[728],{"type":26,"value":729},",\n",{"type":20,"tag":71,"props":731,"children":733},{"class":73,"line":732},3,[734,739,744,749],{"type":20,"tag":71,"props":735,"children":736},{"style":84},[737],{"type":26,"value":738},"  \"tools\"",{"type":20,"tag":71,"props":740,"children":741},{"style":78},[742],{"type":26,"value":743},": [",{"type":20,"tag":71,"props":745,"children":746},{"style":431},[747],{"type":26,"value":748},"\"editor\"",{"type":20,"tag":71,"props":750,"children":751},{"style":78},[752],{"type":26,"value":753},"]\n",{"type":20,"tag":71,"props":755,"children":757},{"class":73,"line":756},4,[758],{"type":20,"tag":71,"props":759,"children":760},{"style":78},[761],{"type":26,"value":603},{"type":20,"tag":34,"props":763,"children":764},{"id":134},[765],{"type":26,"value":134},{"type":20,"tag":138,"props":767,"children":768},{},[769,777],{"type":20,"tag":142,"props":770,"children":771},{},[772],{"type":20,"tag":146,"props":773,"children":775},{"href":774},"/editor",[776],{"type":26,"value":774},{"type":20,"tag":142,"props":778,"children":779},{},[780],{"type":20,"tag":146,"props":781,"children":782},{"href":148},[783],{"type":26,"value":148},{"type":20,"tag":34,"props":785,"children":786},{"id":161},[787],{"type":26,"value":161},{"type":20,"tag":28,"props":789,"children":790},{},[791],{"type":26,"value":792},"在线 JSON 编辑器提供语法高亮、实时校验、行号，无需安装即可编辑 JSON。 JSONDog 提供全套 JSON 在线工具，纯前端、零上传、中英双语，欢迎免费使用。",{"type":20,"tag":170,"props":794,"children":795},{},[796],{"type":26,"value":174},{"title":7,"searchDepth":176,"depth":176,"links":798},[799,800,801,802,803],{"id":671,"depth":176,"text":671},{"id":681,"depth":176,"text":681},{"id":56,"depth":176,"text":56},{"id":134,"depth":176,"text":134},{"id":161,"depth":176,"text":161},"content:blog:json-editor-online.md","blog/json-editor-online.md","blog/json-editor-online",1787305466331]