# read-json-sync

> Read and parse a JSON file synchronously

Latest version **2.0.1** (published 2018-12-16) · ISC license · 0 weekly downloads

## Install

```sh
npm install read-json-sync
pnpm add read-json-sync
yarn add read-json-sync
bun add read-json-sync
```

## Health

**Score 23/100 (F)** — status: abandoned.

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

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.1 |
| Published | 2018-12-16 |
| First published | 2014-10-09 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | separate (@types/read-json-sync) |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 8 |
| Author | Shinnosuke Watanabe |
| Maintainers | shinnn |
| Keywords | data, json, file, read, load, bom, parse, synchronous, synchronously, sync |

## Links

- npm: https://www.npmjs.com/package/read-json-sync
- Repository: https://github.com/shinnn/read-json-sync
- Homepage: https://github.com/shinnn/read-json-sync#readme
- Issues: https://github.com/shinnn/read-json-sync/issues
- npm.io page: https://npm.io/package/read-json-sync

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

- 2.0.1 (latest) — 2018-12-16
- 2.0.0 — 2017-11-15
- 2.0.0-3 — 2017-11-14
- 2.0.0-2 — 2017-11-10
- 2.0.0-1 — 2017-09-13
- 2.0.0-0 — 2017-08-13
- 1.1.1 — 2015-12-04
- 1.1.0 — 2015-02-20
- 1.0.0 — 2014-10-09

## README

# read-json-sync

[![npm version](https://img.shields.io/npm/v/read-json-sync.svg)](https://www.npmjs.com/package/read-json-sync)
[![Build Status](https://travis-ci.com/shinnn/read-json-sync.svg?branch=master)](https://travis-ci.com/shinnn/read-json-sync)
[![Coverage Status](https://img.shields.io/coveralls/shinnn/read-json-sync.svg)](https://coveralls.io/github/shinnn/read-json-sync)

A [Node.js](https://nodejs.org/) module to read and parse a [JSON](https://json.org/) file synchronously

```javascript
const readJsonSync = require('read-json-sync');

readJsonSync('package.json'); //=> {name: 'read-json-sync', version: '1.0.0', ...}
```

Node.js built-in [`require`](https://nodejs.org/api/globals.html#globals_require) and [`import`](https://nodejs.org/api/esm.html#esm_interop_with_existing_modules) can do almost the same thing, but this module doesn't [cache](https://nodejs.org/api/modules.html#modules_caching) results.

## Installation

[Use](https://docs.npmjs.com/cli/install) [npm](https://docs.npmjs.com/about-npm/).

```
npm install read-json-sync
```

## API

```javascript
const readJsonSync = require('read-json-sync');
```

### readJsonSync(*path* [, *options*])

*path*: `string` [`Buffer`](https://nodejs.org/api/buffer.html#buffer_class_buffer) [`URL`](https://nodejs.org/api/url.html#url_class_url) (JSON filename) or `integer` (file descriptor)  
*options*: `Object` `string` ([`fs.readFile`](https://nodejs.org/api/fs.html#fs_fs_readfile_path_options_callback) options or an encoding of the file)  
Return: `any` (parsed [JSON](https://tools.ietf.org/html/rfc7159) data)

It automatically ignores the leading [byte order mark](https://unicode.org/faq/utf_bom.html).

```javascript
// with-bom.json: '\uFEFF{"a": 1}'

JSON.parse('\uFEFF{"a": 1}'); // throws a SyntaxError

readJsonSync('with-bom.json'); //=> {a: 1}
```

## License

[ISC License](./LICENSE) © 2017 - 2018 Shinnosuke Watanabe

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