New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

jsonc-parse

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsonc-parse

A lightweight JSON with Comments parser.

latest
Source
npmnpm
Version
2.0.0
Version published
Weekly downloads
4K
-13.6%
Maintainers
1
Weekly downloads
 
Created
Source

jsonc-parse

npm version npm downloads jsr version

✨ Features

  • ESM Support
  • Tree Shakeable
  • Lightweight

📦 Installation

npm install jsonc-parse

📚 Usage

import { parse, parseFile, parseFileSync } from "jsonc-parse";

// From file async
const jsonCFile = await parseFile("./config.jsonc");

// From file
const jsonCFile = parseFileSync("./config.jsonc");

// From string
const jsonC = parse(`{
  "bar": "foo",
  // This is a comment.
  "foo": /* This is also a comment */ "bar",
}`);

you can also just import the strip function to remove comments from a string.

// or
import { strip } from "jsonc-parse";

import { strip } from "jsonc-parse/strip";

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

📄 License

Published under MIT License.

Keywords

jsonc

FAQs

Package last updated on 04 Nov 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts