Skip to content

This notebook belongs to

Sadat Jubayer

Senior Software Engineer at Premio

If found, please return to hello@jubayer.dev

Vol. 7Seven years of building

Started
January 2020
Everyday tools
TypeScript, Vue, React, Next.js, NestJS, React Native
Education
B.Sc. CSSE, AIUB, 2020
2 min readDev Tool

Try Biome alongside Prettier

Compare Biome and Prettier output on one JavaScript file, then match quote and semicolon settings before switching a repo.

You want to see what Biome would change in a repo that uses Prettier. Running a formatter across the whole tree makes it hard to tell whether the diff comes from a few settings or from the formatter itself. Compare the output for one file first.

Capture both versions of a file

For a small trial, start in a scratch directory with both CLIs available on your shell's path. Save this as sample.js. The example represents a Prettier style with single quotes and semicolons omitted.

const label = (name) => 'Plan: ' + name
console.log(label('Basic'))

Run it with Node and you should see Plan: Basic. Then ask both formatters to print what they would write.

prettier --single-quote --no-semi sample.js > prettier.js
biome format --stdin-file-path=sample.js < sample.js > biome.js
diff -u prettier.js biome.js

With Biome's default JavaScript style, the diff shows double quotes and semicolons on its side. The original file stays in place because neither command writes to it. A status of 1 from diff means it found differences.

The Biome CLI reference describes the stdin option. The filename tells Biome which language to parse. For a real trial, use the filename of an actual source file and run the Prettier command with your project's existing configuration.

Match the two choices and run it again

Save these options in a biome.json in the scratch directory. The object covers just the JavaScript style used in the example.

{
  "javascript": {
    "formatter": {
      "quoteStyle": "single",
      "semicolons": "asNeeded"
    }
  }
}

Repeat the three comparison commands. The diff should print nothing for this file. Biome now uses single quotes and writes semicolons where the code needs them. See the formatter settings.

Try a file with a long expression or a comment before deciding whether the tools agree on the code you care about. Matching individual options can remove mechanical differences without guaranteeing identical output across a project.

I keep the existing formatter in the editor and CI during the trial. If the remaining differences are worth accepting, pick one formatter for each set of files. Otherwise, saving a file with one tool and running the other in CI can keep reintroducing the same diff.