Rust-Based Formatter 'Oxfmt' Enters Beta
Oxfmt, a new code formatter built in Rust, has entered its beta phase. The tool is designed for the JavaScript ecosystem and claims full compatibility with existing Prettier configurations. By leveraging Rust, Oxfmt aims to provide a faster, more resource-efficient drop-in replacement for formatting large codebases, aligning with a trend of using low-level languages for performance-critical developer tooling.
- Benchmarks show Oxfmt is over 30 times faster than Prettier and 3 times faster than Biome on initial runs without a cache. On a large TypeScript file, Oxfmt took 104ms, compared to Prettier's 1.04 seconds. - With the beta release, Oxfmt now passes 100% of Prettier's JavaScript and TypeScript conformance tests, an increase from about 95% compatibility during its alpha phase. The team has actively contributed pull requests back to Prettier to help converge on formatting behavior for edge cases. - Oxfmt is part of the broader Oxc (Oxidation Compiler) project, a toolchain written in Rust that aims to significantly speed up the entire JavaScript development pipeline, including linting (Oxlint), parsing, and minification. The Oxc toolchain will also power Rolldown, the future bundler for the popular build tool Vite. - The project is led by Boshen Chen and falls under the umbrella of VoidZero, a company founded by Vue.js creator Evan You to build a next-generation toolchain for JavaScript. - The beta version introduced several new features since its alpha, including built-in import sorting, automatic sorting for Tailwind CSS classes, and formatting for embedded languages like CSS-in-JS. - This tool is part of a significant trend in the JavaScript ecosystem of rewriting developer tooling in high-performance, low-level languages like Rust and Go to overcome performance bottlenecks. Other tools following this pattern include SWC for transpilation and Turbopack for bundling. - The roadmap towards a stable release includes adding support for the Prettier plugin ecosystem, which would enable formatting for frameworks like Vue, Svelte, and Astro. - For teams interested in migrating, Oxfmt provides an AI-assisted migration prompt and a single command (`pnpm oxfmt --migrate prettier`) to convert existing Prettier configurations.