Big update!Introducing GitHub Bot Commands. Learn more
Socket
Log inDemoInstall

strip-json-comments

Package Overview
Dependencies
0
Maintainers
1
Versions
17
Issues
File Explorer

Advanced tools

strip-json-comments

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

    5.0.0latest
    Github

Version published
Maintainers
1
Weekly downloads
47,794,057
increased by8.77%

Weekly downloads

Readme

Source

strip-json-comments

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.

Install

npm install strip-json-comments

Usage

import stripJsonComments from 'strip-json-comments'; const json = `{ // Rainbows "unicorn": /* ❤ */ "cake" }`; JSON.parse(stripJsonComments(json)); //=> {unicorn: 'cake'}

API

stripJsonComments(jsonString, options?)

jsonString

Type: string

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

options

Type: object

trailingCommas

Type: boolean
Default: false

Strip trailing commas in addition to comments.

whitespace

Type: boolean
Default: true

Replace comments and trailing commas with whitespace instead of stripping them entirely.

Benchmark

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.

Keywords

FAQs

What is strip-json-comments?

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

Is strip-json-comments popular?

The npm package strip-json-comments receives a total of 45,488,608 weekly downloads. As such, strip-json-comments popularity was classified as popular.

Is strip-json-comments well maintained?

We found that strip-json-comments demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.It has 1 open source maintainer collaborating on the project.

Last updated on 22 Jul 2022

Did you know?

Socket installs a Github app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install Socket
Socket[email protected]

Product

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc