Sha256: 653618c470417b49606e4eafa2791c391b1501dc7073d8f25bee7d0f8f4a7ce1

Contents?: true

Size: 1.58 KB

Versions: 120

Compression:

Stored size: 1.58 KB

Contents

# strip-json-comments [![Build Status](https://travis-ci.org/sindresorhus/strip-json-comments.svg?branch=master)](https://travis-ci.org/sindresorhus/strip-json-comments)

> Strip comments from JSON. Lets you use comments in your JSON files!

This is now possible:

```js
{
	// rainbows
	"unicorn": /* ❤ */ "cake"
}
```

It will remove single-line comments `//` and multi-line comments `/**/`.

Also available as a [gulp](https://github.com/sindresorhus/gulp-strip-json-comments)/[grunt](https://github.com/sindresorhus/grunt-strip-json-comments)/[broccoli](https://github.com/sindresorhus/broccoli-strip-json-comments) plugin.

-

*There's also [`json-comments`](https://npmjs.org/package/json-comments), but it's only for Node.js, inefficient, bloated as it also minifies, and comes with a `require` hook, which is :(*


## Install

```sh
$ npm install --save strip-json-comments
```

```sh
$ bower install --save strip-json-comments
```

```sh
$ component install sindresorhus/strip-json-comments
```


## Usage

```js
var json = '{/*rainbows*/"unicorn":"cake"}';
JSON.parse(stripJsonComments(json));
//=> {unicorn: 'cake'}
```


## API

### stripJsonComments(input)

#### input

Type: `string`

Accepts a string with JSON and returns a string without comments.


## CLI

```sh
$ npm install --global strip-json-comments
```

```sh
$ strip-json-comments --help

strip-json-comments input-file > output-file
# or
strip-json-comments < input-file > output-file
```


## Related

- [`strip-css-comments`](https://github.com/sindresorhus/strip-css-comments)


## License

MIT © [Sindre Sorhus](http://sindresorhus.com)

Version data entries

120 entries across 120 versions & 7 rubygems

Version Path
govuk_publishing_components-18.0.0 node_modules/strip-json-comments/readme.md
govuk_publishing_components-17.21.0 node_modules/strip-json-comments/readme.md
govuk_publishing_components-17.20.0 node_modules/strip-json-comments/readme.md
govuk_publishing_components-17.19.1 node_modules/strip-json-comments/readme.md
govuk_publishing_components-17.19.0 node_modules/strip-json-comments/readme.md
govuk_publishing_components-17.18.0 node_modules/strip-json-comments/readme.md
govuk_publishing_components-17.17.0 node_modules/strip-json-comments/readme.md
govuk_publishing_components-17.16.0 node_modules/strip-json-comments/readme.md
govuk_publishing_components-17.15.0 node_modules/strip-json-comments/readme.md
govuk_publishing_components-17.14.0 node_modules/strip-json-comments/readme.md
govuk_publishing_components-17.13.0 node_modules/strip-json-comments/readme.md
govuk_publishing_components-17.12.2 node_modules/strip-json-comments/readme.md
govuk_publishing_components-17.12.1 node_modules/strip-json-comments/readme.md
govuk_publishing_components-17.12.0 node_modules/strip-json-comments/readme.md
govuk_publishing_components-17.11.0 node_modules/strip-json-comments/readme.md
govuk_publishing_components-17.10.0 node_modules/strip-json-comments/readme.md
govuk_publishing_components-17.9.0 node_modules/strip-json-comments/readme.md
govuk_publishing_components-17.8.0 node_modules/strip-json-comments/readme.md
govuk_publishing_components-17.7.0 node_modules/strip-json-comments/readme.md
govuk_publishing_components-17.6.1 node_modules/strip-json-comments/readme.md