# load-json-file

> Read and parse a JSON file

Latest version **7.0.1** (published 2021-09-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install load-json-file
pnpm add load-json-file
yarn add load-json-file
bun add load-json-file
```

## Health

**Score 43/100 (D)** — status: abandoned.

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

Warnings: low downloads.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 7.0.1 |
| Published | 2021-09-13 |
| First published | 2015-09-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/load-json-file) |
| Module format | ESM |
| Node | ^12.20.0 \|\| ^14.13.1 \|\| >=16.0.0 |
| Dependencies | 0 |
| Unpacked size | 5.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 250 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | read, json, parse, file, fs, load |

## Links

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

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

- 7.0.1 (latest) — 2021-09-13
- 7.0.0 — 2021-08-30
- 6.2.0 — 2019-07-11
- 6.1.0 — 2019-06-11
- 6.0.0 — 2019-04-27
- 5.3.0 — 2019-04-06
- 5.2.0 — 2019-02-12
- 5.1.0 — 2018-09-18
- 5.0.0 — 2018-05-06
- 4.0.0 — 2017-11-04
- 3.0.0 — 2017-08-20
- 2.0.0 — 2016-04-30
- 1.1.0 — 2015-11-14
- 1.0.1 — 2015-09-04
- 1.0.0 — 2015-09-02

## README

# load-json-file

> Read and parse a JSON file

It also [strips UTF-8 BOM](https://github.com/sindresorhus/strip-bom).

## Install

```
$ npm install load-json-file
```

## Usage

```js
import {loadJsonFile} from 'load-json-file';

console.log(await loadJsonFile('foo.json'));
//=> {foo: true}
```

## API

### loadJsonFile(filePath, options?)

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

### loadJsonFileSync(filepath, options?)

Returns the parsed JSON.

#### options

Type: `object`

##### beforeParse

Type: `Function`

Applies a function to the JSON string before parsing.

##### reviver

Type: `Function`

Prescribes how the value originally produced by parsing is transformed, before being returned. See the [`JSON.parse` docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#Using_the_reviver_parameter) for more.

## load-json-file for enterprise

Available as part of the Tidelift Subscription.

The maintainers of load-json-file and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-load-json-file?utm_source=npm-load-json-file&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)

## Related

- [write-json-file](https://github.com/sindresorhus/write-json-file) - Stringify and write JSON to a file atomically

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