格式化 JSON

重新縮進和排版源代碼以便阅读;不能代替執行驗證或业务规則檢查。

輸入: 文本結果: 文本

文本輸入

執行後查看結果

範例

Format an invoice identifier without changing its digits

輸入

{"invoice_id":9007199254740995}

Expected answer

{
  "invoice_id": 9007199254740995
}
縮進字串
排序对象鍵
Off
格式化輸出
On
Keep a quoted invoice identifier as a string

輸入

{"invoice_id":"9007199254740995"}

Expected answer

JSON
{
    "invoice_id": "9007199254740995"
}
縮進字串
排序对象鍵
Off
格式化輸出
On
Convert an annotated JSON5 request policy into strict JSON

Make the formatter's permissive input behavior visible, then check the output with a strict JSON parser.

輸入

{ // Request policy
 timeoutMs: 5000,
 retries: 2,
}

Expected answer

JSON
{
    "timeoutMs": 5000,
    "retries": 2
}
縮進字串
排序对象鍵
Off
格式化輸出
On
A support ticket with a zero-prefixed identifier

輸入

{"ticket":"00123","priority":"high"}

Expected answer

JSON
{
    "ticket": "00123",
    "priority": "high"
}
縮進字串
排序对象鍵
Off
格式化輸出
On
An observatory reading with a negative temperature

輸入

{"station":"demo-observatory","temperatureC":-12.5,"open":false}

Expected answer

JSON
{
    "station": "demo-observatory",
    "temperatureC": -12.5,
    "open": false
}
縮進字串
排序对象鍵
Off
格式化輸出
On
A café menu with Unicode and a decimal price

輸入

{"item":"café","price":3.5,"currency":"EUR"}

Expected answer

JSON
{
    "item": "café",
    "price": 3.5,
    "currency": "EUR"
}
縮進字串
排序对象鍵
Off
格式化輸出
On
A safe webhook retry policy

輸入

{"timeoutMs":5000,"retries":2,"enabled":true}

Expected answer

JSON
{
    "timeoutMs": 5000,
    "retries": 2,
    "enabled": true
}
縮進字串
排序对象鍵
Off
格式化輸出
On
An image manifest with a null caption

輸入

{"width":640,"height":480,"caption":null}

Expected answer

JSON
{
    "width": 640,
    "height": 480,
    "caption": null
}
縮進字串
排序对象鍵
Off
格式化輸出
On
A release note with an embedded newline

輸入

{"version":"2.1.0","notes":"Fixed parser\nAdded tests"}

Expected answer

JSON
{
    "version": "2.1.0",
    "notes": "Fixed parser\nAdded tests"
}
縮進字串
排序对象鍵
Off
格式化輸出
On
An empty search result

輸入

{"results":[],"total":0}

Expected answer

JSON
{
    "results": [],
    "total": 0
}
縮進字串
排序对象鍵
Off
格式化輸出
On

相关工具

程式碼整理

操作参考

查看原始技术文檔 (English)