strip-json-comments
- Version 5.0.3
 - Published
 - 8.2 kB
 - No dependencies
 - MIT license
 
Install
npm i strip-json-commentsyarn add strip-json-commentspnpm add strip-json-commentsOverview
Strip comments from JSON. Lets you use comments in your JSON files!
Index
Functions
Type Aliases
Functions
function stripJsonComments
stripJsonComments: (jsonString: string, options?: Options) => string;Strip comments from JSON. Lets you use comments in your JSON files!
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.Parameter jsonString
Accepts a string with JSON.
Returns
A JSON string without comments.
Example 1
import stripJsonComments from 'strip-json-comments';const json = `{// Rainbows"unicorn": "cake"}`;JSON.parse(stripJsonComments(json));//=> {unicorn: 'cake'}
Type Aliases
type Options
type Options = {    /**	Strip trailing commas in addition to comments.
	@default false	*/    readonly trailingCommas?: boolean;
    /**	Replace comments and trailing commas with whitespace instead of stripping them entirely.
	@default true	*/    readonly whitespace?: boolean;};Package Files (1)
Dependencies (0)
No dependencies.
Dev Dependencies (4)
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/strip-json-comments.
- Markdown[](https://www.jsdocs.io/package/strip-json-comments)
 - HTML<a href="https://www.jsdocs.io/package/strip-json-comments"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
 
- Updated .
Package analyzed in 2528 ms. - Missing or incorrect documentation? Open an issue for this package.
 
