# json-comments

> Make your json config file support comments.

Latest version **0.2.1** (published 2013-11-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install json-comments
pnpm add json-comments
yarn add json-comments
bun add json-comments
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.1 |
| Published | 2013-11-25 |
| First published | 2013-03-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 20 |
| Author | Johnny Wong |
| Maintainers | numbcoder |

## Links

- npm: https://www.npmjs.com/package/json-comments
- Repository: https://github.com/numbcoder/json-comments
- Issues: https://github.com/numbcoder/json-comments/issues
- npm.io page: https://npm.io/package/json-comments

## Recent versions

- 0.2.1 (latest) — 2013-11-25
- 0.2.0 — 2013-11-23
- 0.1.1 — 2013-03-25
- 0.1.0 — 2013-03-23

## README

# Json Comments ![NPM version](https://badge.fury.io/js/json-comments.png)

Make your json config support comments.

## Installation

```bash
$ npm install json-comments
```

### Syntax:

```javascript
// require `json-comments` in your main module only once
require('json-comments');
```

### Examples:

`config.json`
```javascript
{
  // this is host
  "host" : "localhost",

  "port" : 3000, //port

  "url" : "https://github.com/numbcoder", /* url */

  /*
  * comments support for json
  */
  "username": "abc"
}
```

`app.js`
```javascript
require('json-comments');
var config = require('./config');

console.log(config);
// ...
```

#### Parse JSON string
```js
var JSONC = require('json-comments');
var fs = require('fs');

var content = fs.readFileSync('./config.json', 'utf8');
// parse JSON String
var config = JSONC.parse(content);

console.log(config);
```

#### Minify the JSON string
```js
var JSONC = require('json-comments');
var fs = require('fs');

var content = fs.readFileSync('./config.json', 'utf8');

// remove comments and spaces from JSON String
var JsonStr = JSONC.minify(content);
```

## License
MIT

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