Using Biome’s Zero‑Config Formatter to Keep JavaScript/TypeScript Code Consistent
Learn how Biome’s zero‑config formatter gives JavaScript/TypeScript projects a consistent style with minimal setup, plus how to tweak it and handle migration from Prettier.
22 Aug 2026, 01:21 UTC

Problem: Inconsistent formatting slows code reviews
When a team shares a JavaScript/TypeScript repository, small differences in indentation, line width, or trailing commas generate noisy diffs. Reviewers spend time arguing about style instead of logic, and CI pipelines can fail because a formatter isn’t run locally. The goal is to enforce a uniform style with minimal setup so developers can focus on writing code.
Thesis: Biome’s built‑in formatter gives you a consistent style out of the box, with optional tweaks via a simple biome.json file.
How Biome detects files and applies defaults
Running biome format --write <path> triggers Biome’s Rust‑based parser to scan the supplied path for files with extensions .js, .ts, .jsx, .tsx, .css, and .json. No configuration file is required for most projects; the tool uses a preset that matches common style guides (e.g., 80‑character line width, space‑based indentation, trailing commas in ES5 style).
Worked example: formatting a mixed‑style file
Consider a file src/utils.js with the following content (indentation mixes tabs and spaces, line length exceeds 80, and trailing commas are missing):
function add(a,b){
return a+b
}
const obj = {
foo: 1,
bar: 2
}
console.log(add(1,2));
To format it, open a terminal in the repository root and run:
# Ensure you have Biome installed locally (e.g., npm i -D @biomejs/biome)
# No special permissions are needed; the command reads and writes files in the current workspace.
biome format --write src/utils.js
After the command finishes, the file will be rewritten with consistent spacing, a line width of 80 characters, and trailing commas where appropriate. You can verify the change by inspecting the file or running git diff to see only style‑related modifications.
Adjusting style with biome.json
If your team prefers a different line width or indent style, create a biome.json at the project root:
{
"formatter": {
"lineWidth": 100,
"indentStyle": "tab",
"trailingComma": "none"
}
}
Running biome format --write . again will now apply these overrides. The file is plain JSON, so it can be version‑controlled alongside your source.
Trade‑off: Migration from Prettier may produce diffs
Because Biome’s formatting rules are not identical to Prettier’s, switching formatters in an existing codebase will generate a noticeable diff. The diff is limited to style changes (whitespace, comma placement, line breaks) and does not alter program semantics. To assess impact, run the formatter on a copy of the repository and review the diff; if the changes are acceptable, commit them as a one‑time style migration.
Actionable closing
Start by installing Biome as a dev dependency, run biome format --write . to see the immediate effect, and add a biome.json only if you need to deviate from the sensible defaults. For continuous integration, add the same command to your lint step; the formatter and linter share the same configuration, reducing setup complexity. Periodically check the output with git diff --check to ensure no unintended whitespace has slipped in.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.