# json-parse-better-errors

> JSON.parse with context information on error

Latest version **1.0.2** (published 2018-03-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install json-parse-better-errors
pnpm add json-parse-better-errors
yarn add json-parse-better-errors
bun add json-parse-better-errors
```

## 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 | 1.0.2 |
| Published | 2018-03-30 |
| First published | 2017-08-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/json-parse-better-errors) |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 70 |
| Author | Kat Marchán |
| Maintainers | zkat |
| Keywords | JSON, parser |

## Links

- npm: https://www.npmjs.com/package/json-parse-better-errors
- Repository: https://github.com/zkat/json-parse-better-errors
- Homepage: https://github.com/zkat/json-parse-better-errors#readme
- Issues: https://github.com/zkat/json-parse-better-errors/issues
- npm.io page: https://npm.io/package/json-parse-better-errors

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

- 1.0.2 (latest) — 2018-03-30
- 1.0.1 — 2017-08-16
- 1.0.0 — 2017-08-15

## README

# json-parse-better-errors [![npm version](https://img.shields.io/npm/v/json-parse-better-errors.svg)](https://npm.im/json-parse-better-errors) [![license](https://img.shields.io/npm/l/json-parse-better-errors.svg)](https://npm.im/json-parse-better-errors) [![Travis](https://img.shields.io/travis/zkat/json-parse-better-errors.svg)](https://travis-ci.org/zkat/json-parse-better-errors) [![AppVeyor](https://ci.appveyor.com/api/projects/status/github/zkat/json-parse-better-errors?svg=true)](https://ci.appveyor.com/project/zkat/json-parse-better-errors) [![Coverage Status](https://coveralls.io/repos/github/zkat/json-parse-better-errors/badge.svg?branch=latest)](https://coveralls.io/github/zkat/json-parse-better-errors?branch=latest)

[`json-parse-better-errors`](https://github.com/zkat/json-parse-better-errors) is a Node.js library for
getting nicer errors out of `JSON.parse()`, including context and position of the parse errors.

## Install

`$ npm install --save json-parse-better-errors`

## Table of Contents

* [Example](#example)
* [Features](#features)
* [Contributing](#contributing)
* [API](#api)
  * [`parse`](#parse)

### Example

```javascript
const parseJson = require('json-parse-better-errors')

parseJson('"foo"')
parseJson('garbage') // more useful error message
```

### Features

* Like JSON.parse, but the errors are better.

### Contributing

The npm team enthusiastically welcomes contributions and project participation! There's a bunch of things you can do if you want to contribute! The [Contributor Guide](CONTRIBUTING.md) has all the information you need for everything from reporting bugs to contributing entire new features. Please don't hesitate to jump in if you'd like to, or even ask us questions if something isn't clear.

All participants and maintainers in this project are expected to follow [Code of Conduct](CODE_OF_CONDUCT.md), and just generally be excellent to each other.

Please refer to the [Changelog](CHANGELOG.md) for project history details, too.

Happy hacking!

### API

#### <a name="parse"></a> `> parse(txt, ?reviver, ?context=20)`

Works just like `JSON.parse`, but will include a bit more information when an
error happens.

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