# @changesets/format

> Detect and format files

Latest version **0.1.2** (published 2026-08-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install @changesets/format
pnpm add @changesets/format
yarn add @changesets/format
bun add @changesets/format
```

## Health

**Score 65/100 (B)** — status: active.

Positive: esm support; no vulnerabilities; has provenance; recently updated; high maintenance score.

Warnings: low downloads; no types; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.1.2 |
| Published | 2026-08-13 |
| First published | 2026-05-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM |
| Node | ^22.11 \|\| ^24 \|\| >=26 |
| Dependencies | 2 |
| Unpacked size | 11.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 5 |
| Author | Changesets |
| Maintainers | emmatown, andarist |

## Links

- npm: https://www.npmjs.com/package/@changesets/format
- Repository: https://github.com/changesets/format
- Issues: https://github.com/changesets/format/issues
- npm.io page: https://npm.io/package/@changesets/format

## Dependencies (2)

- [tinyexec](https://npm.io/package/tinyexec.md) ^1.3.0
- [package-manager-detector](https://npm.io/package/package-manager-detector.md) ^1.8.0

## Recent versions

- 0.1.2 (latest) — 2026-08-13
- 0.1.1 — 2026-07-19
- 0.1.0 — 2026-05-12
- 0.0.0 — 2026-05-12

## README

# @changesets/format

Detect installed code formatters and format files with them.

## Usage

### `detect()`

<!-- NOTE: Docs should match src/detect.ts -->

Detect the preferred formatter used in the project.

```ts
import { detect } from "@changesets/format";

const result = await detect();
// => "prettier"
```

Options can be passed to the first parameter:

- `cwd`: The current working directory to start looking up for the formatter. Defaults to `process.cwd()`.
- `stopDir`: The path to stop traversing up the directory.
- `order`: The order of formatters to check for. Defaults to `["dprint", "deno", "oxfmt", "biome", "prettier"]` (from `defaultDetectOrder`)

### `format()`

Format the given patterns with a specified or auto-detected formatter. It returns `true` if a formatter is found and the formatting process passes (even if the patterns didn't match any files), otherwise returns `false`.

<!-- NOTE: Docs should match src/format.ts -->

```ts
import { format } from "@changesets/format";

await format(["src/index.ts"]);
```

Options can be passed to the second parameter:

- `formatter`: The formatter to use for formatting. It not specified, it will be auto-detected using `detect`. Use `detect` directly if you want to have more control over the detection process.
- `cwd`: The current working directory to start looking up for the formatter and package manager, and to execute the formatter's command from. Defaults to `process.cwd()`.
- `stopDir`: The path to stop traversing up the directory.
- `packageManager`: The package manager to use for executing the formatter's command. If not specified, it will use `package-manager-detector` to detect the package manager.

## Thanks

The core idea of this package is based on [formatly](https://github.com/JoshuaKGoldberg/formatly), but implemented for Changesets' needs. However, it is still generic enough to be used by other projects than Changesets.

## License

MIT

---
_Source: https://npm.io/package/@changesets/format · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
