JavaScript code formatter libraries

Updated Nov 2026

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

Prettier has the most installs and the most GitHub stars.

LibraryMonthly downloadsStarsLast releaseLicense
Prettier
714.1M
52.4KNov 2026MIT
Oxfmt
109.3M
23.5KNov 2026MIT
Biome
102.3M
26.1KNov 2026MIT OR Apache-2.0
JS Beautifier
64.0M
9.0KJun 2026MIT
dprint
1.8M
4.1KNov 2026MIT
Downloads: npm, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

Features compared

LibraryFormats TypeScriptFormats HTMLFormats CSS
PrettierBuilt-inBuilt-inBuilt-in
OxfmtBuilt-inBuilt-inBuilt-in
BiomeBuilt-inBuilt-inBuilt-in
JS BeautifierUndocumentedBuilt-inBuilt-in
dprintVia pluginVia pluginVia plugin
Built-inVia pluginNot documented

Libraries and code examples

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

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.

Limitations

  • 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.

Quickstart

From api.md
$ npm install --save-dev --save-exact prettier@3.10.1
import * as prettier from "prettier";

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

Prettier examples

From open-source projects on GitHub

Oxfmt is a formatter for JavaScript, TypeScript, and other web languages, built on the Oxc compiler stack. Its output starts from what 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

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.

Limitations

  • 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.

Quickstart

From quickstart.md
$ npm add -D oxfmt
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"

Oxfmt examples

From open-source projects on GitHub

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 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

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.

Limitations

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

Quickstart

From README.md
$ npm install --save-dev --save-exact @biomejs/biome
# format files
npx @biomejs/biome format --write

Biome examples

From open-source projects on GitHub

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

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.

Limitations

  • 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.

Quickstart

From README.md
$ npm -g install js-beautify
js-beautify foo.js

JS Beautifier examples

From open-source projects on GitHub

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, Biome, and Oxc, behind the same command.

Downloads / mo
1.8M
Stars
4.1K
Last release
0.65.0
License
MIT

Strengths

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

Limitations

  • 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.

Quickstart

From setup.md
$ npm install -g dprint
dprint init

dprint fmt

dprint examples

From open-source projects on GitHub
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;
}

FAQ

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

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 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.

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.

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

For coding agents

Found your code formatter library? Help your agent use it.

Connect Exa so your coding agent can find the library’s documentation, check its API, and look up implementations while you build.

Run in your terminal

claude plugin install exa@claude-plugins-official