Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including strip-json-comments with all npm packages installed. Try it out:

var stripJsonComments = require("strip-json-comments")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

strip-json-comments v3.1.1

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

strip-json-comments Build Status

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

This is now possible:

    // Rainbows
    "unicorn": /* ❤ */ "cake"

It will replace single-line comments // and multi-line comments /**/ with whitespace. This allows JSON error positions to remain as close as possible to the original source.

Also available as a Gulp/Grunt/Broccoli plugin.


$ npm install strip-json-comments


const json = `{
    // Rainbows
    "unicorn": /* ❤ */ "cake"

//=> {unicorn: 'cake'}


stripJsonComments(jsonString, options?)


Type: string

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


Type: object


Type: boolean
Default: true

Replace comments with whitespace instead of stripping them entirely.


$ npm run bench


Get professional support for this package with a Tidelift subscription
Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies.


RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free