RevealTheme logo

JavaScript格式化工具

為壓縮後的JavaScript加入縮排,並在分號和大括號處換行。

如何使用本工具

  1. 1

    Paste or type your JavaScript into the input textarea.

  2. 2

    Watch the indented version appear live in the output box below as you type — there is no Format button.

  3. 3

    Select the formatted text in the output box and copy it with your keyboard (there is no copy button).

  4. 4

    Scan the result for any line that split inside a string, regex, or comment, and fix those by hand if needed.

什麼是JavaScript格式化工具?

壓縮後的程式碼套件會移除所有空白:便於快速分發,卻讓人難以閱讀。這個基礎格式化工具會恢復縮排,並在分號和大括號處斷行。如需保留註解、遵循ASI規則的生產級重新格式化,請使用Prettier或你編輯器內建的格式化工具。

常見使用場景

  • Eyeballing a minified vendor bundle or one-line snippet to see its rough structure before debugging.

  • Quickly indenting a short config or object literal you pasted from a chat message or log line.

  • Spreading a dense JSON-like object across multiple lines so nesting becomes visible.

  • Teaching or demoing how braces and semicolons map to indentation levels for beginners.

  • Making a compressed third-party script readable enough to locate a specific function or variable.

  • Sanity-checking that brackets are balanced, since unbalanced input leaves the indentation visibly skewed.

常見問題

它和Prettier一樣好嗎?
不:這只是快速的視覺修整。Prettier是基於剖析器的正規格式化工具,能處理本工具無法應對的邊界情況。

相關工具