Skip to main content
Home

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
6 months ago (1.4.0)

strip-json-comments

npm version npm downloads

A fork of sindresorhus/strip-json-comments but with support for CJS & ESM. And some small modifications.

📦 Installation

npm install @luxass/strip-json-comments

📚 Usage

There is a small difference to the original package. You can see it here.

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

const json = `{
  // this is a comment
  "foo": /* this is also a comment */ "bar"
}`;

JSON.parse(strip(json)); // { foo: "bar" }

Differences to sindresorhus/strip-json-comments

The main differences are:

  • This package is published as ESM & CJS
  • And the default export is moved to a named export called strip
- import stripJsonComments from "strip-json-comments";
+ import { strip } from "@luxass/strip-json-comments";

📄 License

Published under MIT License.

Built and signed on
GitHub Actions

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

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

Import symbol

import * as strip_json_comments from "@luxass/strip-json-comments";
or

Import directly with a jsr specifier

import * as strip_json_comments from "jsr:@luxass/strip-json-comments";

Add Package

pnpm i jsr:@luxass/strip-json-comments
or (using pnpm 10.8 or older)
pnpm dlx jsr add @luxass/strip-json-comments

Import symbol

import * as strip_json_comments from "@luxass/strip-json-comments";

Add Package

yarn add jsr:@luxass/strip-json-comments
or (using Yarn 4.8 or older)
yarn dlx jsr add @luxass/strip-json-comments

Import symbol

import * as strip_json_comments from "@luxass/strip-json-comments";

Add Package

vlt install jsr:@luxass/strip-json-comments

Import symbol

import * as strip_json_comments from "@luxass/strip-json-comments";

Add Package

npx jsr add @luxass/strip-json-comments

Import symbol

import * as strip_json_comments from "@luxass/strip-json-comments";

Add Package

bunx jsr add @luxass/strip-json-comments

Import symbol

import * as strip_json_comments from "@luxass/strip-json-comments";