# tiny-jsonc

> An absurdly small JSONC parser.

Latest version **1.0.2** (published 2025-01-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install tiny-jsonc
pnpm add tiny-jsonc
yarn add tiny-jsonc
bun add tiny-jsonc
```

## Health

**Score 40/100 (D)** — status: maintenance-mode.

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

Warnings: low downloads.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2025-01-18 |
| First published | 2023-01-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | fabiospampinato |
| Keywords | jsonc, json, comments, trailing commas, commas, parser, parse |

## Links

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

## 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) — 2025-01-18
- 1.0.1 — 2023-01-19
- 1.0.0 — 2023-01-19

## README

# Tiny JSONC

An absurdly small JSONC parser.

This library works simply by using regexes to strip out comments first and trailing commas second, in order to account for a trailing comma followed by a comment, and then just passing the output to `JSON.parse`.

If you need additional APIs to manipulate JSONC, better error messages, or a full-blown parser, I'd recommend using [`jsonc-simple-parser`](https://github.com/fabiospampinato/jsonc-simple-parser) instead.

## Install

```sh
npm install tiny-jsonc
```

## Usage

```ts
import JSONC from 'tiny-jsonc';

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

## License

MIT © Fabio Spampinato

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