# prettier-plugin-packagejson

> Prettier package.json plugin to make the order of properties nice.

Latest version **3.0.2** (published 2026-03-05) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: has types; no vulnerabilities; has provenance; high maintenance score; high quality score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 3.0.2 |
| Published | 2026-03-05 |
| First published | 2019-03-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 5.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 389 |
| Maintainers | matzkoh |
| Keywords | package.json, plugin, prettier |

## Links

- npm: https://www.npmjs.com/package/prettier-plugin-packagejson
- Repository: https://github.com/matzkoh/prettier-plugin-packagejson
- Homepage: https://github.com/matzkoh/prettier-plugin-packagejson#readme
- Issues: https://github.com/matzkoh/prettier-plugin-packagejson/issues
- npm.io page: https://npm.io/package/prettier-plugin-packagejson

## Dependencies (1)

- [sort-package-json](https://npm.io/package/sort-package-json.md) ^3.6.0

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 3.0.2 (latest) — 2026-03-05
- 3.0.1 — 2026-03-04
- 3.0.0 — 2026-01-20
- 2.5.22 — 2026-01-18
- 2.5.21 — 2026-01-13
- 2.5.20 — 2025-11-28
- 2.5.19 — 2025-07-20
- 2.5.18 — 2025-07-03
- 2.5.17 — 2025-06-27
- 2.5.16 — 2025-06-26
- 2.5.15 — 2025-05-31
- 2.5.14 — 2025-05-19
- 2.5.13 — 2025-05-15
- 2.5.12 — 2025-05-09
- 2.5.11 — 2025-05-05
- … 64 more at https://npm.io/package/prettier-plugin-packagejson/versions

## README

[![npm-badge]][npm]
[![downloads-badge]][npm]
[![actions-badge]][actions]
[![renovate-badge]][renovate]
[![codecov-badge]][codecov]

[npm-badge]: https://img.shields.io/npm/v/prettier-plugin-packagejson
[npm]: https://www.npmjs.com/package/prettier-plugin-packagejson
[downloads-badge]: https://img.shields.io/npm/dw/prettier-plugin-packagejson?color=blue
[actions-badge]: https://github.com/matzkoh/prettier-plugin-packagejson/actions/workflows/release.yml/badge.svg
[actions]: https://github.com/matzkoh/prettier-plugin-packagejson/actions/workflows/release.yml
[renovate-badge]: https://img.shields.io/badge/renovate-enabled-brightgreen
[renovate]: https://renovatebot.com/
[codecov-badge]: https://codecov.io/gh/matzkoh/prettier-plugin-packagejson/branch/master/graph/badge.svg
[codecov]: https://codecov.io/gh/matzkoh/prettier-plugin-packagejson

# prettier-plugin-packagejson

A [Prettier] plugin to sort the keys of a `package.json` file using [sort-package-json].

[prettier]: https://github.com/prettier/prettier
[sort-package-json]: https://github.com/keithamus/sort-package-json

## Installation

```sh
npm i -D prettier prettier-plugin-packagejson
```

For prettier v3+ you need to configure

```js
module.exports = {
  // add this
  plugins: ['prettier-plugin-packagejson'],
}
```

## Options

### `packageSortOrder`

Custom ordering array for `package.json` fields. This option is passed to [sort-package-json]'s `sortOrder` option.

**Type:** `string[]`
**Default:** `[]` (uses default sort order from sort-package-json)

Example (`.prettierrc`):

```json
{
  "packageSortOrder": ["name", "version", "description", "main"]
}
```

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