1 # strip-json-comments [](https://travis-ci.org/sindresorhus/strip-json-comments)
3 > Strip comments from JSON. Lets you use comments in your JSON files!
10 "unicorn": /* ❤ */ "cake"
14 It will remove single-line comments `//` and multi-line comments `/**/`.
16 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 and a [require hook](https://github.com/uTest/autostrip-json-comments).
19 *There's already [json-comments](https://npmjs.org/package/json-comments), but it's only for Node.js and uses a naive regex to strip comments which fails on simple cases like `{"a":"//"}`. This module however parses out the comments.*
25 $ npm install --save strip-json-comments
29 $ bower install --save strip-json-comments
33 $ component install sindresorhus/strip-json-comments
40 var json = '{/*rainbows*/"unicorn":"cake"}';
41 JSON.parse(stripJsonComments(json));
42 //=> {unicorn: 'cake'}
48 ### stripJsonComments(input)
54 Accepts a string with JSON and returns a string without comments.
60 $ npm install --global strip-json-comments
64 $ strip-json-comments --help
66 strip-json-comments input-file > output-file
68 strip-json-comments < input-file > output-file
74 MIT © [Sindre Sorhus](http://sindresorhus.com)