# jsonc-reader

> A simple reader for JSONC

Latest version **0.3.0** (published 2025-03-19) · ISC license · 0 weekly downloads

## Install

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

## Health

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

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

Warnings: low downloads; pre 1.0.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.0 |
| Published | 2025-03-19 |
| First published | 2021-10-12 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Kevin Goslar |
| Maintainers | kevingoslar |

## Links

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

## Recent versions

- 0.3.0 (latest) — 2025-03-19
- 0.2.0 — 2025-03-13
- 0.1.2 — 2025-02-28
- 0.1.1 — 2025-02-28
- 0.1.0 — 2025-02-28
- 0.0.3 — 2021-10-12
- 0.0.2 — 2021-10-12
- 0.0.1 — 2021-10-12

## README

# JSONC reader for TypeScript

![test status](https://github.com/kevgo/jsonc-reader-ts/actions/workflows/tests.yml/badge.svg)
[![Code Coverage](https://coveralls.io/repos/github/kevgo/jsonc-reader-ts/badge.svg?branch=main)](https://coveralls.io/github/kevgo/jsonc-reader-ts?branch=main)
[![0 dependencies](https://img.shields.io/badge/dependencies-0-brightgreen.svg)](https://github.com/kevgo/node-text-stream-search/blob/main/package.json)
[![install size](https://packagephobia.now.sh/badge?p=jsonc-reader)](https://packagephobia.now.sh/result?p=jsonc-reader)

This micro-library (no dependencies) allows reading JSON that contain comments
(JSONC). It does that by overwriting comments with whitespace - so that line and
column numbers remain the same - and then loading the data as normal JSON.

```ts
import * as jsonc from "jsonc-reader"

// load JSONC from a file
const config = await jsonc.load("../my-config.jsonc")

// parse a JSONC string
const jsoncText = `
{
  // a comment
  "one": 1  // another comment
}`
const config = jsonc.parse(jsoncText)
// config === { one: 1 }

// strip comments from a JSONC string
const jsonText = jsonc.strip(jsoncText)
// jsonText === `
// {
//
//   "one": 1
// }`
```

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