代码格式化工具
在浏览器中美化 JavaScript、TypeScript、JSON、CSS、HTML、Markdown 等代码。 由 Prettier 3 提供支持。无需上传、无需配置、无需注册。
输入
输出
A tiny, in-browser Prettier playground
Prettier is the de-facto standard for code formatting in the JavaScript world. It enforces a consistent style across files, languages and contributors so teams stop arguing about spaces and semicolons. FreeLabTools wraps Prettier in a zero-setup web UI: paste your code, pick a language, click Format.
支持的语言
We ship Prettier's official plugins so the output matches what you'd get in any Prettier- configured project:
- JavaScript, TypeScript, JSX / React — modern syntax including ES2024, decorators, optional chaining.
- JSON, JSON5 — compact data, plus the more relaxed JSON5 with comments and trailing commas.
- CSS, SCSS, Less — full stylesheet support with selector grouping.
- HTML — including embedded scripts and styles.
- Markdown — table alignment, list normalization, code fence padding.
- YAML — useful for cleaning Docker, Kubernetes, GitHub Actions configs.
- GraphQL — schema and query formatting.
性能:为什么速度快
Prettier's standalone bundle is small (~85 KB), but each language plugin can be 100-800 KB. Loading them all upfront would slow the first paint. Instead, this page loads plugins on demand: when you pick TypeScript, only the TypeScript plugin downloads. On a typical connection the first format takes about half a second; subsequent ones are instant.
隐私
Everything runs inside the browser tab — Prettier itself executes locally. Your code is never sent to a server. The only network traffic is the (one-time) download of Prettier's public assets from a CDN.
使用场景
- Quickly clean up a JSON or YAML file before pasting it into a config.
- Fix the indentation of a snippet from a forum or chat.
- Apply your project's style to one-off scripts without installing Node.
- Teach Prettier defaults to new team members.
常见问题
- 代码格式化器支持哪些编程语言?
- 支持 JavaScript/TypeScript、HTML、CSS/SCSS/Less、JSON、Markdown、Python、Java、C/C++、C#、PHP、Go、Rust、Ruby、Swift、Kotlin、SQL、YAML、XML 和 GraphQL——总共超过 20 种语言。
- 代码格式化器会上传我的代码吗?
- 不会。所有格式化都在您的浏览器中使用 Prettier(用于 JS/TS/HTML/CSS/JSON/Markdown/GraphQL/YAML)和自定义格式化器(用于 Python、Java、Go 等)完成。您的代码永远不会离开设备。
- 格式化选项可以自定义吗?
- 可以。您可以调整缩进类型(空格或制表符)、缩进宽度(2/4/8)、行宽、引号样式、分号偏好等。设置会自动保存到浏览器本地存储。
- 代码格式化器如何工作?
- 该工具使用 Prettier(从 CDN 加载)作为主要格式化引擎处理支持的语言,并为其他语言使用自定义的基于规则的格式化器。解析和格式化完全在浏览器中的 JavaScript 中完成。
- 代码格式化器免费吗?有使用限制吗?
- 完全免费,没有使用限制、文件大小限制或注册要求。由于所有处理都在浏览器中进行,唯一的限制是设备内存。适合处理任何大小的代码片段。