biome/packages/@biomejs/js-api
github-actions[bot] fd282fc5f4
Some checks failed
Benchmarks Configuration / Bench (push) Waiting to run
Benchmarks CSS / Bench (push) Waiting to run
Benchmarks GraphQL / Bench (push) Waiting to run
Benchmarks JS / Bench (push) Waiting to run
Benchmarks JSON / Bench (push) Waiting to run
Benchmarks Module Graph / Bench (push) Waiting to run
Lint rule docs / Validate rules documentation (push) Waiting to run
Repository dispatch on main / Build @biomejs/wasm-web (push) Waiting to run
Repository dispatch on main / Repository dispatch (push) Blocked by required conditions
Benchmarks Manifests / Bench (push) Has been cancelled
ci: release (#7916)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-11-03 09:19:46 +00:00
..
scripts ci: fix beta release for JS API (#5462) 2025-03-26 21:55:01 +09:00
src feat(lint): add useBiomeIgnoreFolder and noBiomeFirstException (#7159) 2025-08-11 13:41:43 +01:00
tests chore: fix various typos across codebase (#7216) 2025-08-14 11:12:41 +09:00
CHANGELOG.md ci: release (#7824) 2025-10-24 08:56:25 +01:00
LICENSE-APACHE docs(LICENSE-APACHE): fill copyright placeholder (#1166) 2023-12-13 16:34:35 +01:00
LICENSE-MIT chore: add Apache 2.0 license to npm packages (#745) 2023-11-16 09:58:53 -06:00
package.json ci: release (#7916) 2025-11-03 09:19:46 +00:00
README.md fix(js-api): don't use types of others modules (#6535) 2025-07-01 19:09:25 +02:00
ROME-LICENSE-MIT fix(package): add ROME MIT license (#949) 2023-11-28 23:47:01 +01:00
tsconfig.json chore: format package.json like npm does (#3155) 2024-06-10 11:09:27 +01:00
vitest.config.ts chore: improve pnpm usage (#2069) 2024-03-14 15:31:16 +00:00

Biome JavaScript Bindings

Official JavaScript bindings for Biome

Warning

The API is currently in alpha. It is not yet ready for production use. We appreciate your support and feedback as we work to make it ready for everyone.

Installation

npm i @biomejs/js-api
npm i @biomejs/wasm-<dist>

You need to install one of the @biomejs/wasm-* package as a peer dependency for this package to work correctly, out of the following distributions:

  • @biomejs/wasm-bundler: Install this package if you're using a bundler that supports importing *.wasm files directly
  • @biomejs/wasm-nodejs: Install this package if you're using Node.js to load the WebAssembly bundle use the fs API
  • @biomejs/wasm-web: Install this package if you're targeting the web platform to load the WASM bundle using the fetch API

Usage

import { Biome } from "@biomejs/js-api/nodejs";
// Or:
// import { Biome, Distribution } from "@biomejs/js-api/bundler";
// import { Biome, Distribution } from "@biomejs/js-api/web";

const biome = new Biome();
const { projectKey } = biome.openProject("path/to/project/dir");

// Optionally apply a Biome configuration (instead of biome.json)
biome.applyConfiguration(projectKey, {...});

const formatted = biome.formatContent(
  projectKey,
  "function f   (a, b) { return a == b; }",
  {
    filePath: "example.js",
  },
);

console.log("Formatted content: ", formatted.content);

const result = biome.lintContent(projectKey, formatted.content, {
  filePath: "example.js",
});

const html = biome.printDiagnostics(result.diagnostics, {
  filePath: "example.js",
  fileSource: formatted.content,
});

console.log("Lint diagnostics: ", html);

Philosophy

The project philosophy can be found on our website.

Community

Contribution and development instructions can be found in Contributing.

Additional project coordination and real-time discussion happens on our Discord server. Remember that all activity on the Discord server is still moderated and will be strictly enforced under the project's Code of Conduct.