跳到內文

STEMSTUDIO

Format JSON and find what is broken

Data · formatted on this device

Format JSON and find what is broken

Pretty-print, minify or sort JSON. If it is broken, see exactly which line and why.

  • Free, no account
  • Nothing is sent

Help

The position and reason above are worked out by this page. This is the browser’s own wording, kept for reference. These come from a text search, so one of them may simply be sitting inside a string value.

Processing, communication and stored data

貼上 JSON 即可美化、壓縮或按鍵排序。解析失敗時,會給出行和列,引用出錯的那一行並在下面用 ^ 標出位置,還會用簡單的話說明尾逗號、註釋等 JSON 悄悄禁止的東西。

支援格式

JSON

常見問題

我貼上的 JSON 會被上傳嗎?

不會。解析、格式化和校驗都在頁面中進行,貼上的內容從不傳送到伺服器。關閉標籤頁就消失。

能處理多大的輸入?

沒有硬性上限——取決於你的裝置。幾 MB 很輕鬆。大約超過 200KB 時實時格式化會關閉,出現一個“格式化”按鈕,因為每次按鍵都重新解析幾 MB 會讓打字本身卡頓。

能幫我修復壞掉的 JSON 嗎?

不能。刪掉尾逗號是安全的,但把單引號換成雙引號可能會弄壞字串裡的撇號。所以不會自動改寫,而是顯示位置和原因。

行號是瀏覽器給的嗎?

不是——交給瀏覽器,正是大多數格式化工具無法顯示行號的原因。輸入稍長時,Chrome 返回的是片段而不是位置,Safari 則從不包含位置。所以這個頁面自己分析語法,找到文件最先出錯的地方,再從那裡數出行和列。說明(“這個逗號後面什麼都沒有”)也來自同一次分析;瀏覽器自己的提示保留在下面供參考。格式化仍由瀏覽器的標準解析器完成,所以輸出和其他地方讀取 JSON 的方式一致。

按鍵排序有什麼用?

讓對比穩定。內容相同但鍵的順序不同的兩個檔案,比較時會產生干擾;先把兩者都排序,就只剩真正的差異。順序按 Unicode 碼元排列,在任何機器上都一樣。

Ratings from users

Ratings appear once there are 10.

Report a problem or suggest something

The tool name, this page’s path and your browser type are sent with it. Files are never sent. For a reply, use the email on the Contact page.