# read-pkg

> Read a package.json file

Latest version **10.1.0** (published 2026-02-08) · MIT license · 0 weekly downloads

> **Better alternative:** See documentation for alternatives (https://github.com/AikidoSec/module-replacements/blob/main/docs/read-pkg)

## Install

```sh
npm install read-pkg
pnpm add read-pkg
yarn add read-pkg
bun add read-pkg
```

## Health

**Score 60/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 10.1.0 |
| Published | 2026-02-08 |
| First published | 2015-09-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=20 |
| Dependencies | 5 |
| Unpacked size | 6.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 176 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | json, read, parse, file, fs, graceful, load, package, normalize |

## Links

- npm: https://www.npmjs.com/package/read-pkg
- Repository: https://github.com/sindresorhus/read-pkg
- Homepage: https://github.com/sindresorhus/read-pkg#readme
- Issues: https://github.com/sindresorhus/read-pkg/issues
- Funding: https://github.com/sponsors/sindresorhus
- npm.io page: https://npm.io/package/read-pkg

## Dependencies (5)

- [type-fest](https://npm.io/package/type-fest.md) ^5.4.4
- [parse-json](https://npm.io/package/parse-json.md) ^8.3.0
- [unicorn-magic](https://npm.io/package/unicorn-magic.md) ^0.4.0
- [normalize-package-data](https://npm.io/package/normalize-package-data.md) ^8.0.0
- [@types/normalize-package-data](https://npm.io/package/@types/normalize-package-data.md) ^2.4.4

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

- 10.1.0 (latest) — 2026-02-08
- 10.0.0 — 2025-11-07
- 9.0.1 — 2023-11-16
- 9.0.0 — 2023-11-02
- 8.1.0 — 2023-08-22
- 8.0.0 — 2023-04-07
- 7.1.0 — 2022-02-08
- 7.0.0 — 2021-08-14
- 6.0.0 — 2021-03-28
- 5.2.0 — 2019-07-11
- 5.1.1 — 2019-04-27
- 5.1.0 — 2019-04-24
- 5.0.0 — 2019-03-10
- 4.0.1 — 2018-06-26
- 4.0.0 — 2018-06-25
- … 4 more at https://npm.io/package/read-pkg/versions

## README

# read-pkg

> Read a package.json file

## Why

- [Throws more helpful JSON errors](https://github.com/sindresorhus/parse-json)
- [Normalizes the data](https://github.com/npm/normalize-package-data#what-normalization-currently-entails)

## Install

```sh
npm install read-pkg
```

## Usage

```js
import {readPackage} from 'read-pkg';

console.log(await readPackage());
//=> {name: 'read-pkg', …}

console.log(await readPackage({cwd: 'some-other-directory'}));
//=> {name: 'unicorn', …}
```

## API

### readPackage(options?)

Returns a `Promise<object>` with the parsed JSON.

### readPackageSync(options?)

Returns the parsed JSON.

#### options

Type: `object`

##### cwd

Type: `URL | string`\
Default: `process.cwd()`

Current working directory.

##### normalize

Type: `boolean`\
Default: `true`

[Normalize](https://github.com/npm/normalize-package-data#what-normalization-currently-entails) the package data.

### parsePackage(packageFile, options?)

Parses an object or string into JSON.

#### packageFile

Type: `object | string`

An object or a stringified object to be parsed as a package.json.

#### options

Type: `object`

##### normalize

Type: `boolean`\
Default: `true`

[Normalize](https://github.com/npm/normalize-package-data#what-normalization-currently-entails) the package data.

## Related

- [read-package-up](https://github.com/sindresorhus/read-package-up) - Read the closest package.json file
- [write-package](https://github.com/sindresorhus/write-package) - Write a `package.json` file
- [load-json-file](https://github.com/sindresorhus/load-json-file) - Read and parse a JSON file

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