Picture your usual workflow: you make a tiny two-line commit, hit save, the pre-commit hook kicks in—and your laptop freezes for a solid fifteen to twenty seconds. The fans spin up, your train of thought evaporates, and Prettier slowly churns through thousands of project files in the terminal. If that same check runs on a CI server where dozens of pipelines spin up in parallel, those waiting minutes snowball into hours of engineering downtime and hefty cloud runner bills.
The Bun team, led by Jarred Sumner, has been methodically building out their all-in-one toolchain vision. We are already used to Bun running JavaScript and TypeScript fast, going toe-to-toe with Node.js, and installing dependencies in a blink. With the major Bun v1.4.4 update, the runtime takes a long-awaited step toward code hygiene: a native bun fmt formatter is now baked right into the binary.
I tested the tool on real monorepos, poked around its internal architecture, and I'm ready to break down where that absurd speed comes from, how compatibility with existing standards works, and why switching over won't force your team to rewrite its style rules.
Anatomy of Speed: Why Classic Prettier Hit a Ceiling
To appreciate the engineering behind this, let's look at where time actually went in the traditional stack. Prettier is a fantastic tool that became the de facto standard for the web. The catch is that it's written in JavaScript and runs inside the Node.js VM.
Whenever Prettier runs on a large repository, the pipeline hits unavoidable overhead:
- Slow startup of the Node.js runtime itself, followed by sequentially loading hundreds of modules from
node_modules. - Building an Abstract Syntax Tree (AST) for every source file, allocating hundreds of thousands of tiny objects on the JS heap.
- Frequent main-thread pauses as the Garbage Collector cleans up temporary structures.
- Single-threaded parsing that barely scratches the surface of modern multi-core CPUs.
The Bun team took a completely different route. bun fmt itself is written in systems languages—Zig and C++. Its formatting engine for JavaScript and TypeScript was ported directly from oxc_formatter (part of the Oxc project by VoidZero), which distilled the best architectural ideas from Biome's formatter. As a result, parsing and formatted code generation happen in a monolithic native memory block with zero VM overhead.
Look at the benchmark numbers. On the official Prettier repository (2,616 files), running:
bun fmt --check
finishes in just 59.7 ms with a peak memory footprint of 48 MB. By comparison, Prettier 3.9.10 on the exact same file set takes 17.1 s and consumes 459 MB of RAM. That is a 286x speedup while using roughly 10x less memory. Even against the Rust-based oxfmt 0.74.0 formatter from Vite (2,537 files), bun fmt finishes in 65.2 ms versus 406.7 ms—more than 6x faster.
Earlier, we looked at how Bun v1.4.3 introduced native type checking with bun check, eliminating the painful tsc bottleneck. Pairing fast type checking with instant formatting now covers both core pre-commit quality gates.
Multi-Language Support and Embedded Fragments
You might reasonably ask: "Did they only get this speed by gutting features? Surely it only handles plain JS and chokes on complex templates?" Not at all. bun fmt was designed from the ground up as a drop-in Prettier replacement across the web platform:
- JS, TS, JSX, TSX, Flow, CSS, SCSS, Less;
- HTML, Vue, Svelte, Angular, LWC, Handlebars, MJML;
- Markdown, MDX, GraphQL, JSON, JSONC, YAML, TOML.
Bun's parser cleanly detects embedded language boundaries (such as <style> blocks inside Vue or HTML, or CSS inside template literals) and formats them in a single native process without inter-process context switching.
Config Compatibility and Built-In Plugins
Every tech lead's worst nightmare when switching formatters is a massive diff touching hundreds of thousands of lines over minor whitespace or trailing-brace quirks. The Bun team paid close attention to compatibility.
The tool automatically discovers and respects your existing configs: .prettierrc*, prettier.config.*, the "prettier" key in package.json, .editorconfig rules, .prettierignore, and Oxc configs (.oxfmtrc.json, oxfmt.config.ts).
If you prefer a single configuration hub for the whole Bun toolchain, you can set all formatting options directly in bunfig.toml.
# bunfig.toml — centralized formatting configuration for the project
[fmt]
printWidth = 100
semi = false
singleQuote = true
trailingComma = "all"
indentWidth = 2
sortImports = true
sortTailwindcss = true
sortPackageJson = true
jsdoc = true
# Per-path overrides for test files
[[fmt.overrides]]
files = ["*.test.ts", "tests/**/*.ts"]
options = { printWidth = 120, semi = true }
Notice the built-in sortImports and sortTailwindcss options. Previously with Prettier, sorting import statements required external plugins like @trivago/prettier-plugin-sort-imports, and ordering utility classes meant adding prettier-plugin-tailwindcss. Both plugins slowed checks down noticeably.
In bun fmt, that logic lives right in the core:
- On-the-fly import sorting groups built-in libraries, external npm packages, local aliases, and relative paths.
- The Tailwind sorter supports both v3 and v4 class conventions, keeping markup predictable.
- The
package.jsonnormalizer orders standard manifest keys into the conventional canonical layout.
If you are migrating a repository to Bun, run bun fmt --doctor. The utility inspects your active configs and prints the exact list of Prettier packages and third-party plugins you can safely strip from your project dependencies.
Git Integration and CI/CD Automation
Nobody wants to format files by hand before every push. For Git workflows, the team built in bun fmt --staged.
Infographic diagram of the Git index showing direct file validation via bun fmt while bypassing the lint-staged layer.
Previously, almost everyone leaned on lint-staged for this. It queried Git for changed files via Node.js, piped them to an external Prettier process, and re-added them to the index with git add. bun fmt --staged handles the entire chain directly: it reads staged files, formats them in place, and updates the Git index immediately without intermediary overhead.
#!/bin/sh
# .git/hooks/pre-commit — instant pre-commit hook
bun fmt --staged
For automated checks on your build server, just wire up standard scripts in your manifest:
{
"scripts": {
"format": "bun fmt",
"format:check": "bun fmt --check"
}
}
bun fmt --check exits with a non-zero status code whenever any style drift is detected, making it a fast, low-cost step for any CI pipeline.
Edge Cases and Compatibility Nuances
Across the vast majority of standard syntax, bun fmt produces output that is byte-for-byte identical to Prettier. However, in a few rare edge cases where Prettier historically introduced syntax bugs, the Bun team chose correctness:
- In CSS rules with escaped characters like
font-family: Font\ Awesome, classic Prettier mistakenly stripped the backslash, breaking icon fonts. Bun leaves the escape intact. - In Handlebars templates containing
<!DOCTYPE html>, the legacy parser mangled the root node structure. - In JSX template literals like
className={\btn ${active ? "on" : "off"}`}`, older Prettier versions sometimes dropped significant whitespace before interpolations. Bun preserves whitespace reliably.
The one real caveat: if your project relies on custom Prettier plugins that execute arbitrary JavaScript to construct non-standard ASTs, Bun's native engine cannot run them. In those cases, you can temporarily keep classic Prettier for those specific files while moving the rest of your codebase to bun fmt.
Companion Optimizations in Bun v1.4.4
Beyond the formatter, v1.4.4 ships a solid batch of subsystem upgrades:
- Faster
bun install: Linux optimizations speed up cached installs by up to 3.2x, alongside musl/glibc binary filtering and pnpm-style peer dependency support. - Bun.SQL and SQLite tuning: up to 48% lower CPU usage per query, PostgreSQL
COPYstream support, and array serialization. - WebSocket stack: fixed a close-handshake bug that could drop trailing messages.
Practical Takeaway
bun fmt is a textbook example of how a modern systems language and thoughtful data architecture can breathe new life into everyday web tooling. Being able to check and format several thousand files in under a tenth of a second changes how you work with code—eliminating those tedious pre-commit pauses for good.


