# prettier-plugin-toml

> An opinionated `toml` formatter plugin for Prettier

Latest version **3.0.2** (published 2026-09-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install prettier-plugin-toml
pnpm add prettier-plugin-toml
yarn add prettier-plugin-toml
bun add prettier-plugin-toml
```

## Health

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

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

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 3.0.2 |
| Published | 2026-09-24 |
| First published | 2019-02-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=18.0.0 |
| Dependencies | 3 |
| Unpacked size | 73 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 356 |
| Author | Ray (https://mk1.io) <i@mk1.io> |
| Maintainers | jounqin |
| Keywords | toml, plugin, prettier, prettier-plugin |

## Links

- npm: https://www.npmjs.com/package/prettier-plugin-toml
- Repository: git+https://github.com/un-ts/prettier.git
- Homepage: https://github.com/un-ts/prettier/tree/master/packages/toml
- Funding: https://opencollective.com/unts
- npm.io page: https://npm.io/package/prettier-plugin-toml

## Dependencies (3)

- [smol-toml](https://npm.io/package/smol-toml.md) ^1.8.0
- [@tombi-toml/wasm-lib](https://npm.io/package/@tombi-toml/wasm-lib.md) ^1.5.5
- [@dual-bundle/import-meta-resolve](https://npm.io/package/@dual-bundle/import-meta-resolve.md) ^4.2.1

## Alternatives

- [eslint-plugin-sonarjs](https://npm.io/package/eslint-plugin-sonarjs.md) — 2.9M weekly downloads
- [eslint-config-expo](https://npm.io/package/eslint-config-expo.md) — 1.5M weekly downloads
- [@matter/protocol](https://npm.io/package/@matter/protocol.md) — 63.5K weekly downloads
- [@eventcatalog/linter](https://npm.io/package/@eventcatalog/linter.md) — 24.8K weekly downloads
- [@inrupt/eslint-config-base](https://npm.io/package/@inrupt/eslint-config-base.md) — 4.5K weekly downloads

## Recent versions

- 3.0.2 (latest) — 2026-09-24
- 1.0.1 (release-v1) — 2024-02-12
- 3.0.1 — 2026-09-24
- 3.0.0 — 2026-09-24
- 2.0.6 — 2025-07-10
- 2.0.5 — 2025-05-09
- 2.0.4 — 2025-04-06
- 2.0.3 — 2025-03-29
- 2.0.2 — 2025-02-20
- 2.0.1 — 2023-11-27
- 2.0.0 — 2023-11-27
- 1.0.0 — 2023-08-02
- 0.4.0 — 2023-08-02
- 0.3.5 — 2023-08-02
- 0.3.4 — 2023-08-02
- … 3 more at https://npm.io/package/prettier-plugin-toml/versions

## README

# prettier-plugin-toml ![npm bundle size](https://img.shields.io/bundlephobia/min/prettier-plugin-toml) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/prettier-plugin-toml)

> An opinionated `toml` formatter plugin for [Prettier][]

Prettier is an opinionated code formatter. It enforces a consistent style by parsing your code and re-printing, taking various rules into account.

This plugin adds support for `toml` through [tombi][].

## Notice

This plugin is still under development, its printer just wraps [tombi][]'s default printer.
Of course it should just work, but may not match [prettier][]'s format sometimes.

## Requirements

`prettier-plugin-toml` is an evergreen module. 🌲 This module requires an [LTS](https://github.com/nodejs/Release) Node version (v18.0.0+).

## Install

Using npm:

```sh
# npm
npm i -D prettier prettier-plugin-toml

# yarn
yarn add -D prettier prettier-plugin-toml
```

## Usage

Once installed, [Prettier plugins](https://prettier.io/docs/en/plugins.html) must be added to `.prettierrc`:

```json
{
  "plugins": ["prettier-plugin-toml"]
}
```

Then:

```sh
# npx
npx prettier --write foo.toml

# yarn
yarn prettier --write foo.toml
```

## Configuration

Besides the options below, this plugin reads [tombi][]'s own configuration,
following its [search priority][tombi-config]:

1. **Project** — for each directory from the formatted file's directory up to
   the filesystem root: `.tombi.toml`, `tombi.toml`, `.config/tombi.toml`, then
   `[tool.tombi]` in `pyproject.toml`.
2. **User** — `$XDG_CONFIG_HOME/tombi/config.toml`,
   `~/.config/tombi/config.toml`, plus the platform specific
   `~/Library/Application Support/tombi/config.toml` (macOS) or
   `%APPDATA%\tombi\config.toml` (Windows).
3. **System** — `/etc/tombi/config.toml`.

The rules are resolved in order, each step overriding the previous one:

1. Tombi's and Prettier's defaults.
2. The discovered configuration's `[format.rules]`.
3. Prettier options that are explicitly set — a value equal to Prettier's
   default (for example `printWidth: 80`) does not count as explicit.
4. The discovered configuration's per-file `[[overrides]]`, applied by Tombi
   last.

### Notes

- Tombi's schema lookup is always disabled, so formatting stays offline and
  deterministic.
- Discovered configuration files are cached per directory and polled (best
  effort), so edits to them apply without restarting the process. A newly
  created project configuration applies on the next run.

## Parser Options

[prettier][]'s own core options are inherited and mapped to their tombi
counterparts where they exist:

- `printWidth` → `line-width`
- `tabWidth` → `indent-width`
- `useTabs` → `indent-style`
- `singleQuote` → `string-quote-style`
- `bracketSpacing` → `inline-table-brace-space-width`

`endOfLine` is handled by [prettier][] itself. All of tombi's other format rules
are exposed as `toml` options and can be used to override the inherited values:

```ts
interface PrettierOptions {
  // The TOML version to use when parsing and formatting.
  tomlVersion: 'v1.0.0' | 'v1.1.0-preview' | 'v1.1.0' // default `v1.0.0`
  // The number of spaces inside the brackets of a single line array.
  arrayBracketSpaceWidth: number // default `0`
  // The number of spaces after the comma in a single line array.
  arrayCommaSpaceWidth: number // default `1`
  // The style used to format comments.
  commentStyle: 'normalize' | 'preserve' // default `normalize`
  // The delimiter between date and time.
  dateTimeDelimiter: 'preserve' | 'space' | 'T' // default `T`
  // The blank lines limit between groups.
  groupBlankLinesLimit: number // default `1`
  // Whether to indent sub-tables.
  indentSubTables: boolean // default `false`
  // Whether to indent table key-value pairs.
  indentTableKeyValuePairs: boolean // default `false`
  // The number of spaces inside the braces of a single line inline table,
  // defaults to `bracketSpacing` (`1` or `0`).
  inlineTableBraceSpaceWidth: number // default `bracketSpacing`
  // The number of spaces after the comma in a single line inline table.
  inlineTableCommaSpaceWidth: number // default `1`
  // Whether to align the equals sign in key-value pairs.
  keyValueEqualsSignAlignment: boolean // default `false`
  // The preferred quote character for keys, defaults to `stringQuoteStyle`.
  keyQuoteStyle: 'double' | 'preserve' | 'single' // default `undefined`
  // The preferred quote character for strings, defaults to `singleQuote`.
  stringQuoteStyle: 'double' | 'preserve' | 'single' // default `singleQuote`
  // Whether to align the trailing comments in key-value pairs.
  trailingCommentAlignment: boolean // default `false`
  // The number of spaces around the equals sign in a key-value pair.
  keyValueEqualsSignSpaceWidth: number // default `1`
  // The number of blank lines between tables.
  tableBlankLines: number // default `1`
  // The number of spaces before a trailing comment.
  trailingCommentSpaceWidth: number // default `2`
}
```

## Sponsors and Backers

[![Sponsors and Backers](https://raw.githubusercontent.com/1stG/static/master/sponsors.svg)](https://github.com/sponsors/JounQin)

### Sponsors

| 1stG                                                                                                                   | RxTS                                                                                                                   | UnTS                                                                                                                   |
| ---------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
| [![1stG Open Collective sponsors](https://opencollective.com/1stG/organizations.svg)](https://opencollective.com/1stG) | [![RxTS Open Collective sponsors](https://opencollective.com/rxts/organizations.svg)](https://opencollective.com/rxts) | [![UnTS Open Collective sponsors](https://opencollective.com/unts/organizations.svg)](https://opencollective.com/unts) |

### Backers

| 1stG                                                                                                                | RxTS                                                                                                                | UnTS                                                                                                                |
| ------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- |
| [![1stG Open Collective backers](https://opencollective.com/1stG/individuals.svg)](https://opencollective.com/1stG) | [![RxTS Open Collective backers](https://opencollective.com/rxts/individuals.svg)](https://opencollective.com/rxts) | [![UnTS Open Collective backers](https://opencollective.com/unts/individuals.svg)](https://opencollective.com/unts) |

## Changelog

Detailed changes for each release are documented in [CHANGELOG.md](./CHANGELOG.md).

## License

[MIT][] © [Ray][]@[mk1.io][]

[mk1.io]: https://mk1.io
[mit]: http://opensource.org/licenses/MIT
[prettier]: https://prettier.io
[ray]: https://github.com/so1ve
[tombi]: https://github.com/tombi-toml/tombi
[tombi-config]: https://tombi-toml.github.io/tombi/docs/configuration

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