Skip to main content

Built and signed on GitHub Actions

strip comments from your json

This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
88%
Published
3 months ago (1.3.2)
function strip
strip(
jsonString: string,
options?: Options,
): string

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

Examples

Example 1

import { strip } from "@luxass/strip-json-comments";

const json = `{
  // this is a comment
  "foo": "bar"
}`;
JSON.parse(strip(json)); // { foo: "bar" }

Parameters

jsonString: string
  • The JSON string to strip comments from
optional
options: Options = DEFAULT_OPTIONS
  • The options to use

Return Type

A JSON string without comments.

Add Package

deno add jsr:@luxass/strip-json-comments

Import symbol

import { strip } from "@luxass/strip-json-comments";

---- OR ----

Import directly with a jsr specifier

import { strip } from "jsr:@luxass/strip-json-comments";

Add Package

npx jsr add @luxass/strip-json-comments

Import symbol

import { strip } from "@luxass/strip-json-comments";

Add Package

yarn dlx jsr add @luxass/strip-json-comments

Import symbol

import { strip } from "@luxass/strip-json-comments";

Add Package

pnpm dlx jsr add @luxass/strip-json-comments

Import symbol

import { strip } from "@luxass/strip-json-comments";

Add Package

bunx jsr add @luxass/strip-json-comments

Import symbol

import { strip } from "@luxass/strip-json-comments";