# JavaScript code formatter libraries

JavaScript code formatters rewrite source files in one consistent style for indentation, line breaks, quotes, and semicolons. These libraries run in editors, pre-commit hooks, and CI to keep code written by developers and coding agents in one style.

## Popularity

| Library | Monthly downloads | Stars | Last release | License |
| --- | --- | --- | --- | --- |
| [Prettier](#prettier) | 714.1M | 52.4K | Nov 2026 | MIT |
| [Oxfmt](#oxfmt) | 109.3M | 23.5K | Nov 2026 | MIT |
| [Biome](#biome) | 102.3M | 26.1K | Nov 2026 | MIT OR Apache-2.0 |
| [JS Beautifier](#js-beautifier) | 64.0M | 9.0K | Jun 2026 | MIT |
| [dprint](#dprint) | 1.8M | 4.1K | Nov 2026 | MIT |

Downloads: npm, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

[Prettier](#prettier) has the most installs and the most GitHub stars.

## Capabilities

| Library | Formats TypeScript | Formats HTML | Formats CSS |
| --- | --- | --- | --- |
| [Prettier](#prettier) | Yes | Yes | Yes |
| [Oxfmt](#oxfmt) | Yes | Yes | Yes |
| [Biome](#biome) | Yes | Yes | Yes |
| [JS Beautifier](#js-beautifier) | Undocumented | Yes | Yes |
| [dprint](#dprint) | Via plugin | Via plugin | Via plugin |

## Libraries

### Prettier

[GitHub](https://github.com/prettier/prettier) · [npm](https://www.npmjs.com/package/prettier) · [Docs](https://github.com/prettier/prettier/blob/deda65fd47c285b974e2a4397f26a33cfc1746b8/docs/api.md)

Prettier parses source code and reprints it from scratch in one consistent style, discarding the original formatting. When a line exceeds the print width, Prettier breaks it up, putting each argument of a long function call on its own line. Supported languages include JavaScript, TypeScript, JSX, CSS, HTML, JSON, GraphQL, Markdown, and YAML. From JavaScript, `prettier.format` takes the source text and an options object. Its `parser` option sets the language, or `filepath` lets Prettier infer the language from the file extension. A second function, `prettier.check`, reports whether a file is formatted, the same check the `--check` flag runs in CI.

- Downloads / mo: 714.1M
- Stars: 52.4K
- Last release: 3.10.1
- License: MIT
- Capabilities: [From the Prettier docs](https://github.com/prettier/prettier/blob/deda65fd47c285b974e2a4397f26a33cfc1746b8/docs/api.md)

**Strengths**

- **Reads project settings.** Finds the config file for each source file before formatting it.
- **Picks the parser from the file name.** Pass a file path, and Prettier chooses the language parser.

**Watch out for**

- **Async API.** Every API call returns a promise. Synchronous use needs the separate `@prettier/sync` package.
- **Few style options.** Prettier describes itself as opinionated. Most layout choices are fixed rather than configurable.

```sh
npm install --save-dev --save-exact prettier@3.10.1
```

**prettier/prettier-vscode** (5.5K stars)

[prettier/prettier-vscode](https://github.com/prettier/prettier-vscode) 

```typescript
public async format(
    source: string,
    options?: Options | undefined,
  ): Promise<string> {
    if (!this.prettierModule) {
      await this.import();
    }
    return this.prettierModule!.format(source, options);
  }

```

[src/PrettierDynamicInstance.ts](https://github.com/prettier/prettier-vscode/blob/b3d5ea136fadf5a4cac835df074dc12fcb398b0c/src/PrettierDynamicInstance.ts#L55-L63) · [More projects using Prettier →](https://dashboard.exa.ai/playground/search?q=TypeScript%20projects%20using%20prettier%20for%20source%20formatting%2C%20configuration%20resolution%2C%20range%20formatting%20and%20embedded%20language%20plugins&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```typescript
import * as prettier from "prettier";

await prettier.format("foo ( );", { semi: false, parser: "babel" });
// -> 'foo()\n'

```

From [api.md](https://github.com/prettier/prettier/blob/deda65fd47c285b974e2a4397f26a33cfc1746b8/docs/api.md)

### Oxfmt

[GitHub](https://github.com/oxc-project/oxc) · [npm](https://www.npmjs.com/package/oxfmt) · [Docs](https://oxc.rs/docs/guide/usage/formatter/quickstart)

Oxfmt is a formatter for JavaScript, TypeScript, and other web languages, built on the Oxc compiler stack. Its output starts from what [Prettier](#prettier) prints. A project migrating from a recent Prettier version sees few formatting differences. The Oxfmt team treats any unexpected difference as a bug. Import sorting, Tailwind CSS class sorting, and package.json field sorting come built in, where Prettier needs plugins. The `oxfmt` command formats files in place. With `--check`, the command lists unformatted files and leaves their contents unchanged.

- Downloads / mo: 109.3M
- Stars: 23.5K
- Last release: 0.79.0
- License: MIT
- Capabilities: [From the Oxfmt docs](https://oxc.rs/docs/guide/usage/formatter/quickstart)

**Strengths**

- **Sorting built in.** Sorts imports, Tailwind CSS classes, and package.json fields without plugins.
- **Takes source text directly.** Call format() with a file name, the source text, and options.

**Watch out for**

- **No Prettier plugins.** Prettier plugins don't load. Oxfmt builds in the most popular ones instead.
- **Different defaults.** The default print width is a hundred characters, compared with eighty in Prettier. A `prettier` field in package.json isn't read.

```sh
npm add -D oxfmt
```

**zwave-js/zwave-js** (898 stars)

[zwave-js/zwave-js](https://github.com/zwave-js/zwave-js) 

```typescript
export async function formatWithOxfmt(
	filename: string,
	sourceText: string,
	options?: Partial<FormatConfig>,
): Promise<string> {
	const { code, errors } = await format(filename, sourceText, {
		...(await getFormatOptions(filename)),
		...options,
	});
	if (errors.length) {
		throw new Error(
			errors
				.map((error) => error.codeframe ?? error.message)
				.join("\n\n"),
		);
	}
	return code;
}

```

[packages/maintenance/src/oxfmt.ts](https://github.com/zwave-js/zwave-js/blob/e17a1f131e36c96bd2975f5642b3be386abebd93/packages/maintenance/src/oxfmt.ts#L71-L88) · [More projects using Oxfmt →](https://dashboard.exa.ai/playground/search?q=TypeScript%20projects%20using%20oxfmt%20for%20source%20formatting%2C%20configuration%20resolution%2C%20range%20formatting%20and%20embedded%20language%20plugins&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```typescript
import { format, type FormatOptions } from "oxfmt";

const input = `let a=42;`;
const options: FormatOptions = {
  semi: false,
};

const { code } = await format("a.js", input, options);
console.log(code); // "let a = 42"

```

From [quickstart.md](https://raw.githubusercontent.com/oxc-project/website/main/src/docs/guide/usage/formatter/quickstart.md)

### Biome

[GitHub](https://github.com/biomejs/biome) · [npm](https://www.npmjs.com/package/@biomejs/biome) · [Docs](https://raw.githubusercontent.com/biomejs/biome/main/packages/@biomejs/biome/README.md)

Biome is a toolchain that formats and lints JavaScript, TypeScript, JSX, JSON, CSS, GraphQL, HTML, and other web languages in one program. The formatter matches [Prettier](#prettier) on about ninety-seven percent of cases. A linter with more than seven hundred and fifty rules, drawn from ESLint, typescript-eslint, and other sources, ships in the same binary. On the command line, `biome format --write` formats files, while `biome check --write` runs formatting, linting, and safe fixes together. Biome runs without Node.js.

- Downloads / mo: 102.3M
- Stars: 26.1K
- Last release: 2.6.8
- License: MIT OR Apache-2.0
- Capabilities: [From the Biome docs](https://raw.githubusercontent.com/biomejs/biome/main/packages/@biomejs/biome/README.md)

**Strengths**

- **Formats and lints together.** One command runs the formatter, the linter, and import organizing.
- **Same settings in editor and CLI.** One biome.json applies to both the command line and the editor.

**Watch out for**

- **Prettier differences.** Output differs from Prettier on a small share of cases. Switching formatters produces some diffs to review.

```sh
npm install --save-dev --save-exact @biomejs/biome
```

**calcom/cal.diy** (50.2K stars)

[calcom/cal.diy](https://github.com/calcom/cal.diy) 

```typescript
const formatFileWithBiome = (filePath: string) => {
  // Normalize to forward slashes for cross-platform Biome compatibility
  const normalizedPath = filePath.replace(/\\/g, "/");
  const { status } = spawnSync(
    "yarn",
    ["biome", "format", "--write", "--no-errors-on-unmatched", normalizedPath],
    {
      stdio: "inherit",
      cwd: repoRoot,
      shell: true,
    }
  );

  if (status !== 0) {
    throw new Error(`Biome formatting failed for ${filePath}`);
  }
};

```

[packages/app-store-cli/src/build.ts](https://github.com/calcom/cal.diy/blob/ae027bb70e694e2d2c44569f398d6cbcee0389b1/packages/app-store-cli/src/build.ts#L16-L32) · [More projects using Biome →](https://dashboard.exa.ai/playground/search?q=TypeScript%20projects%20using%20%40biomejs/biome%20for%20source%20formatting%2C%20configuration%20resolution%2C%20range%20formatting%20and%20embedded%20language%20plugins&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```typescript
# format files
npx @biomejs/biome format --write

```

From [README.md](https://raw.githubusercontent.com/biomejs/biome/main/packages/@biomejs/biome/README.md)

### JS Beautifier

[GitHub](https://github.com/beautifier/js-beautify) · [npm](https://www.npmjs.com/package/js-beautify) · [Docs](https://github.com/beautifier/js-beautify/blob/20ff725dbe9fe28fbf779c3ef38efdd827cea995/README.md)

JS Beautifier reformats and re-indents JavaScript. The same tool unpacks packed scripts and partly deobfuscates obfuscated code. The npm package, `js-beautify`, installs a command-line program and three library functions: `js_beautify`, `css_beautify`, and `html_beautify`. Each function takes a string of code and an options object, such as `indent_size` for the indent width. A Python port, `jsbeautifier`, formats JavaScript only.

- Downloads / mo: 64.0M
- Stars: 9.0K
- Last release: 2.0.3
- License: MIT
- Capabilities: [From the JS Beautifier docs](https://github.com/beautifier/js-beautify/blob/20ff725dbe9fe28fbf779c3ef38efdd827cea995/README.md)

**Strengths**

- **One function per language.** Call the JavaScript, CSS, or HTML beautifier on a string of code.
- **Fine-grained spacing options.** Set indent size and spacing options on each call.

**Watch out for**

- **Fewer HTML options.** The CSS and HTML beautifiers are simpler in scope and have far fewer options than the JavaScript one.
- **Few maintainers.** The README asks for contributors because the current owners have very limited time for the project.

```sh
npm -g install js-beautify
```

**HookyQR/VSCodeBeautify** (603 stars)

[HookyQR/VSCodeBeautify](https://github.com/HookyQR/VSCodeBeautify) 

```typescript
const beautifyDocRanges = (doc, ranges, type, formattingOptions, isPartial) => {
  if (!doc) {
    vscode.window.showInformationMessage(
      'Beautify can\'t get the file information because the editor won\'t supply it. (File probably too large)');
    throw '';
  }
  return Promise.resolve(type ? type : getBeautifyType())
    .then(type => options(doc, type, formattingOptions)
      .then(config => removeNewLineEndForPartial(config, isPartial))
      .then(config => Promise.all(ranges.map(range =>
        beautify[type](doc.getText(range), config)))));
};

```

[extension.js](https://github.com/HookyQR/VSCodeBeautify/blob/6dfff2f014acb7358ef67aadc77bc0aa8f255e7e/extension.js#L34-L45) · [More projects using JS Beautifier →](https://dashboard.exa.ai/playground/search?q=TypeScript%20projects%20using%20js-beautify%20for%20source%20formatting%2C%20configuration%20resolution%2C%20range%20formatting%20and%20embedded%20language%20plugins&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```typescript
js-beautify foo.js

```

From [README.md](https://raw.githubusercontent.com/beautifier/js-beautify/main/README.md)

### dprint

[GitHub](https://github.com/dprint/dprint) · [npm](https://www.npmjs.com/package/dprint) · [Docs](https://raw.githubusercontent.com/dprint/dprint/main/README.md)

dprint is a command-line formatter that runs the language plugins a project lists in a `dprint.json` file. `dprint init` creates that file and preselects plugins that match the files in the directory. After setup, `dprint fmt` formats the project. A second command, `dprint check`, lists unformatted files. Plugins cover TypeScript, JSON, Markdown, TOML, Dockerfiles, and SQL. Wrapper plugins run other formatters, such as [Prettier](#prettier), [Biome](#biome), and Oxc, behind the same command.

- Downloads / mo: 1.8M
- Stars: 4.1K
- Last release: 0.65.0
- License: MIT
- Capabilities: [From the dprint docs](https://raw.githubusercontent.com/dprint/dprint/main/README.md)

**Strengths**

- **Wraps other formatters.** Plugins run Prettier, Biome, or Oxc behind the same dprint command.

**Watch out for**

- **Config file first.** Formatting reads the plugin list from `dprint.json`. A new project runs `dprint init` before the first `dprint fmt`.
- **One plugin per language.** A language is formatted only after its plugin is added to the config.

```sh
npm install -g dprint
```

**liquity/bold** (140 stars)

[liquity/bold](https://github.com/liquity/bold) 

```javascript
async function format(content: string) {
  const dprint = $`dprint fmt --stdin tsx`.quiet();
  dprint.stdin.write(content);
  dprint.stdin.end();
  const { stdout } = await dprint;
  return stdout;
}

```

[frontend/uikit/scripts/update-icons.ts](https://github.com/liquity/bold/blob/d262669ef3c4d37bf0544df3bb2624c07b8a5ee0/frontend/uikit/scripts/update-icons.ts#L111-L117) · [More projects using dprint →](https://dashboard.exa.ai/playground/search?q=dprint%20GitHub%20projects)

**Quickstart**

```javascript
dprint init

dprint fmt

```

From [setup.md](https://raw.githubusercontent.com/dprint/dprint/main/website/src/setup.md)

## FAQ

### Which JavaScript formatter should I use?

Use [Prettier](#prettier) by default. It has the most downloads by far, at 714.1M a month. Choose [Biome](#biome) to replace Prettier and ESLint with one tool, or [Oxfmt](#oxfmt) for Prettier-style output that runs much faster.

### ESLint vs Prettier: do I need both?

Yes, for most projects. Prettier formats code, and ESLint catches bugs. Turn off the ESLint style rules that conflict with Prettier so the two tools don't fight.

### Biome vs Prettier: which should I use?

Biome formats and lints in one pass, and `biome migrate prettier` copies existing Prettier settings into Biome. Its defaults differ from Prettier's, so review the output after switching. Stay on Prettier for projects that rely on its plugins.

### Oxfmt vs Prettier: can I switch?

Yes, in most projects. Oxfmt uses Prettier's output as its baseline, so projects on a recent Prettier version see few differences. Oxfmt doesn't load Prettier plugins, but it builds in import sorting and Tailwind CSS class sorting.

### How do I check formatting in CI?

Run `prettier . --check`. The command fails when any file isn't formatted, without changing the files.

## How this page was built

Data checked Nov 18, 2026.

Reproduce it with the Exa API:

```json
{
  "endpoint": "/search",
  "body": {
    "query": "Best JavaScript code formatter libraries Prettier JS Beautifier dprint Biome CLI code examples Oxfmt",
    "numResults": 5
  }
}
```

Docs: https://exa.ai/docs/reference/search
