What is BiomeJS? A Complete Guide to the Rust-Powered Web Toolchain
BiomeJS is a fast, unified toolchain written in Rust that combines code formatting, linting, parsing, and Language Server Protocol (LSP) support into a single high-performance tool, offering approximately 97% compatibility with Prettier and over 500 linting rules for web technologies.
BiomeJS (commonly referred to as Biome) is an open-source project hosted in the biomejs/biome repository that aims to simplify JavaScript tooling by consolidating fragmented workflows into one cohesive solution. By leveraging Rust for performance-critical operations, BiomeJS eliminates the need to configure and maintain separate tools like Prettier, ESLint, and individual language servers. The project provides both a command-line interface and programmatic JavaScript APIs via WebAssembly bindings, making it accessible across Node.js environments and modern browsers.
Core Components of BiomeJS
BiomeJS delivers four primary capabilities through a unified architecture designed to handle malformed code robustly while maintaining high performance.
Formatter
The formatter provides ~97% compatibility with Prettier across JavaScript, TypeScript, JSX, JSON, CSS, and GraphQL. According to the packages/@biomejs/biome/README.md, this component handles complex formatting decisions while maintaining deterministic output. The formatter core resides in crates/biome_formatter/src/lib.rs, which implements the formatting algorithm for all supported languages through a shared engine.
Linter
The linter enforces code quality through more than 500 rules drawn from ESLint, typescript-eslint, and other sources. Implemented in crates/biome_analyze/src/lib.rs, the linter provides detailed, contextual diagnostics with automatic fix application. The analysis engine supports robust error recovery, allowing it to lint code even when syntax errors are present.
Parser and LSP
The parser infrastructure builds on a full-fidelity AST with robust error recovery capabilities. Language-specific parsers include crates/biome_js_parser/src/lib.rs for JavaScript/TypeScript/JSX, crates/biome_css_parser/src/lib.rs for CSS, and crates/biome_graphql_parser/src/lib.rs for GraphQL queries. The Language Server Protocol (LSP) implementation enables real-time editor integrations that function on malformed code as you type, providing immediate feedback during development.
Architecture Overview
The BiomeJS repository is organized into Rust crates under crates/ and JavaScript packages under packages/.
The core Rust architecture includes:
biome_formatter/- Rust formatter enginebiome_analyze/- Linter implementation and rule registrybiome_parser/- Language-agnostic parser generatorbiome_cli/- Command-line front-endbiome_js_parser/,biome_css_parser/,biome_graphql_parser/- Language-specific parsers
The JavaScript ecosystem bindings include:
@biomejs/biome/- NPM package exposing the CLI@biomejs/js-api/- Node.js WebAssembly bindings@biomejs/wasm-web/- Browser WebAssembly bindings@biomejs/plugin-api/- Plugin extension points
Using the BiomeJS CLI
The command-line interface defined in crates/biome_cli/src/main.rs provides intuitive commands for code maintenance. You can execute BiomeJS via npx without installation:
# Format an entire project
npx @biomejs/biome format --write .
# Lint and automatically apply safe fixes
npx @biomejs/biome lint --write .
# Run both format and lint in one step
npx @biomejs/biome check --write .
# CI mode that fails on any issue
npx @biomejs/biome ci
The CLI parses configuration from biome.json, with schema generation handled in xtask/codegen/src/generate_configuration.rs.
JavaScript API Integration
BiomeJS exposes its Rust core through WebAssembly, enabling programmatic usage in both Node.js and browser environments.
Node.js API
The @biomejs/js-api package defined in packages/@biomejs/js-api/src/biome.ts provides asynchronous methods for formatting and linting:
import { Biome, Distribution } from "@biomejs/js-api";
async function formatAndLint(code) {
const biome = await Biome.create({ distribution: Distribution.NODE });
// Format code
const formatted = await biome.formatContent({
language: "js",
sourceText: code,
});
// Lint the formatted code
const lintResult = await biome.lintContent({
language: "js",
sourceText: formatted.code,
});
console.log("Formatted:", formatted.code);
console.log("Diagnostics:", lintResult.diagnostics);
}
This API is tested in packages/@biomejs/js-api/tests/formatContent.test.ts.
Browser WebAssembly API
For browser environments, BiomeJS loads from packages/@biomejs/wasm-web/src/lib.rs:
<script type="module">
import { Biome, Distribution } from "https://cdn.jsdelivr.net/npm/@biomejs/js-api/dist/web.js";
async function run() {
const biome = await Biome.create({ distribution: Distribution.WEB });
const result = await biome.formatContent({
language: "tsx",
sourceText: "<div>Hello</div>",
});
console.log(result.code);
}
run();
</script>
The web build powers the online playground and supports the same formatting and linting capabilities as the Node.js version.
Summary
- BiomeJS is a Rust-based toolchain combining formatting, linting, parsing, and LSP support for web languages.
- The formatter achieves ~97% Prettier compatibility across JavaScript, TypeScript, JSX, JSON, CSS, and GraphQL.
- The linter provides 500+ rules with automatic fixes and robust error recovery.
- Architecture separates concerns into Rust crates (
biome_formatter,biome_analyze,biome_*_parser) and JavaScript packages (@biomejs/js-api,@biomejs/wasm-web). - Usage options include CLI commands (
format,lint,check,ci), Node.js APIs via WebAssembly, and browser integrations. - Key source files include
crates/biome_cli/src/main.rsfor CLI entry,crates/biome_formatter/src/lib.rsfor formatting logic, andcrates/biome_analyze/src/lib.rsfor linting rules.
Frequently Asked Questions
What languages does BiomeJS support?
BiomeJS supports JavaScript, TypeScript, JSX, JSON, CSS, and GraphQL. Each language has a dedicated parser crate (e.g., crates/biome_js_parser/src/lib.rs for JavaScript/TypeScript, crates/biome_css_parser/src/lib.rs for CSS, and crates/biome_graphql_parser/src/lib.rs for GraphQL), all unified under a common formatting and analysis engine.
How does BiomeJS compare to Prettier?
BiomeJS achieves approximately 97% compatibility with Prettier while offering significantly faster performance due to its Rust implementation. Unlike Prettier, BiomeJS also includes built-in linting capabilities with over 500 rules, eliminating the need to run separate formatting and linting tools.
Can I use BiomeJS programmatically in my build tools?
Yes. BiomeJS exposes JavaScript APIs through the @biomejs/js-api package, which loads the Rust core via WebAssembly. You can create a Biome instance with Biome.create({ distribution: Distribution.NODE }) and call methods like formatContent() and lintContent() to process code programmatically without spawning CLI processes.
Is BiomeJS suitable for CI/CD pipelines?
Absolutely. The npx @biomejs/biome ci command is specifically designed for continuous integration environments, returning non-zero exit codes when issues are detected. This makes it ideal for pre-commit hooks and automated quality checks in CI/CD workflows.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →