# jsonc-simple-parser

> A simple JSON parser that supports comments and optional trailing commas.

Latest version **3.0.0** (published 2022-11-09) · 0 weekly downloads

## Install

```sh
npm install jsonc-simple-parser
pnpm add jsonc-simple-parser
yarn add jsonc-simple-parser
bun add jsonc-simple-parser
```

## Health

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

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

Warnings: low downloads.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2022-11-09 |
| First published | 2021-03-08 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 351.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 33 |
| Maintainers | fabiospampinato |
| Keywords | jsonc, json, comments, trailing commas, commas, parser, parse, stringify, tiny, simple |

## Links

- npm: https://www.npmjs.com/package/jsonc-simple-parser
- Repository: https://github.com/fabiospampinato/jsonc-simple-parser
- Homepage: https://github.com/fabiospampinato/jsonc-simple-parser#readme
- Issues: https://github.com/fabiospampinato/jsonc-simple-parser/issues
- npm.io page: https://npm.io/package/jsonc-simple-parser

## Dependencies (1)

- [reghex](https://npm.io/package/reghex.md) ^3.0.2

## 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.0 (latest) — 2022-11-09
- 2.2.1 — 2022-03-21
- 2.2.0 — 2021-04-12
- 2.1.0 — 2021-03-20
- 2.0.0 — 2021-03-18
- 1.0.1 — 2021-03-10
- 1.0.0 — 2021-03-08

## README

# JSONC Simple Parser

A simple JSON parser that supports comments and optional trailing commas.

## Features

- **Tiny**:
  - It's ~3.5kb minified and gzipped, if you aren't already using [RegHex](https://github.com/kitten/reghex), otherwise it's just ~2kb.
  - Even if you aren't using [RegHex](https://github.com/kitten/reghex) already (you should) that's ~32% smaller than VS Code's [jsonc-parser](https://www.npmjs.com/package/jsonc-parser) and ~62% smaller than [JSON5](https://www.npmjs.com/package/json5).
- **Performant**:
  - When parsing regular JSON it's ~10x faster than VS Code's [jsonc-parser](https://www.npmjs.com/package/jsonc-parser), ~70x faster than [JSON5](https://www.npmjs.com/package/json5) and just as fast as the native `JSON.parse`.
  - When parsing JSON with comments or trailing commas it's just as fast as VS Code's [jsonc-parser](https://www.npmjs.com/package/jsonc-parser) and ~6x faster than [JSON5](https://www.npmjs.com/package/json5).
- **Tested**:
  - It passes all 274 tests regarding JSON from ECMA's [test262](https://github.com/tc39/test262) test suite.
  - The parser is obviously not spec compliant but this means that while adding support for comments and trailing commas probably nothing else got broken.

## Install

```sh
npm install --save jsonc-simple-parser
```

## Usage

```ts
import JSONC from 'jsonc-simple-parser';

const source = `
  { // This is an example
    "foo": 123,
    /* TRAILING COMMAS */
    "bar": [1, 2, 3,],
  }
`;

const result = {
  foo: 123,
  bar: [1, 2, 3]
};

JSONC.parse ( source ); // => returns an object that's deeply equal to `result`
JSONC.stringify ( result ); // => same as calling `JSON.stringify`
```

## License

MIT © Fabio Spampinato

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