DEV Community

Alex Spinov
Alex Spinov

Posted on

Biome Has a Free API You've Never Heard Of

Biome is a fast formatter and linter for JavaScript, TypeScript, JSX, JSON, CSS, and GraphQL. Written in Rust, it's 35x faster than Prettier and replaces ESLint + Prettier with a single tool.

What Makes Biome Special?

  • 35x faster than Prettier — Rust-powered performance
  • All-in-one — formatting + linting in one tool
  • 200+ lint rules — covers ESLint, TypeScript ESLint, and more
  • Zero config — works out of the box
  • Editor integration — VS Code, IntelliJ, Neovim

The Hidden API: Programmatic Usage

import { Biome, Distribution } from '@biomejs/js-api';

const biome = await Biome.create({ distribution: Distribution.NODE });

// Format code programmatically
const formatted = biome.formatContent('const x={a:1,b:2,c:3}', {
  filePath: 'file.ts'
});
console.log(formatted.content);
// const x = { a: 1, b: 2, c: 3 };

// Lint code
const linted = biome.lintContent(
  'let unused = 5; console.log("hello");',
  { filePath: 'file.ts' }
);
for (const diagnostic of linted.diagnostics) {
  console.log(diagnostic.message);
}
Enter fullscreen mode Exit fullscreen mode

Configuration API

{
  "$schema": "https://biomejs.dev/schemas/1.9.0/schema.json",
  "formatter": {
    "indentStyle": "space",
    "indentWidth": 2,
    "lineWidth": 100
  },
  "linter": {
    "rules": {
      "recommended": true,
      "complexity": {
        "noExcessiveCognitiveComplexity": { "level": "warn", "options": { "maxAllowedComplexity": 15 } }
      },
      "performance": {
        "noBarrelFile": "error",
        "noReExportAll": "error"
      },
      "style": {
        "useNamingConvention": { "level": "warn" }
      }
    }
  },
  "organizeImports": { "enabled": true }
}
Enter fullscreen mode Exit fullscreen mode

CLI API

# Format
biome format --write src/

# Lint
biome lint src/

# Both at once
biome check --write src/

# CI mode — error on issues
biome ci src/

# Migrate from ESLint + Prettier
biome migrate eslint --write
biome migrate prettier --write
Enter fullscreen mode Exit fullscreen mode

Quick Start

npm install --save-dev @biomejs/biome
npx biome init
npx biome check --write src/
Enter fullscreen mode Exit fullscreen mode

Why Teams Switch to Biome

A developer shared: "Our ESLint + Prettier CI step took 45 seconds. Biome does the same job in 1.2 seconds. We also deleted 500 lines of ESLint config and 3 plugins. One tool, one config file, done."


Optimizing your dev toolchain? Email spinov001@gmail.com or check my tools.

ESLint + Prettier or Biome? What's your linting setup?

Top comments (0)