Skip to content

格式化与代码

JavaScript / TypeScript 格式化工具

免费的 JavaScript 和 TypeScript 格式化工具。完全在浏览器中运行 Prettier 的默认规则 — 从类型注解自动检测 TypeScript。粘贴、点击、复制即可。

Runs in your browser
JavaScript / TypeScript formatter & validator
lines: 0chars: 0size: 0 B
JavaScript / TypeScript · UTF-8 · 2-space indent

编辑注

Understanding · JS, set to a house style.

本深度章节目前仅有英文版本。上方的转换工具支持您的语言;长篇说明文章尚未翻译。

常见问题

Quick answers.

Does it handle TypeScript?

Yes — the tool auto-detects TypeScript from type annotations (`: string`, `interface Foo`, `type X = ...`) and routes to Prettier's TS parser. You don't have to toggle anything.

Which Prettier options does it use?

Prettier's out-of-box defaults: 2-space indent, semicolons, double quotes, 80-column print width, trailing commas. These match the vast majority of published codebases.

Will it change my code's behaviour?

No — Prettier only reformats; it never changes semantics. The output runs identically to the input, byte-for-byte after transpilation.

Can it minify JavaScript?

No — Prettier is a formatter, not a minifier. For production minification use Terser, esbuild or SWC locally. They produce far smaller output than a whitespace collapser would.

大家也在搜索

相关工具

More in this room.

查看所有 格式化与代码