npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@jsonic/jsonc

v0.8.0

Published

This plugin allows the Jsonic JSON parser to support JSONC syntax.

Readme

@jsonic/jsonc

This plugin allows the Jsonic JSON parser to parse JSONC format files (JSON with Comments).

JSONC is a strict superset of JSON that adds single-line (//) and block (/* */) comments. Trailing commas in objects and arrays can be optionally enabled.

npm version build Coverage Status Known Vulnerabilities

| Voxgig | This open source module is sponsored and supported by Voxgig. | | ---------------------------------------------------- | --------------------------------------------------------------------------------------- |

The documentation below is organized along the Diátaxis quadrants:

Quick start

TypeScript

Install:

npm install @jsonic/jsonc @jsonic/jsonic-next

Parse:

import { Jsonic } from '@jsonic/jsonic-next'
import { Jsonc } from '@jsonic/jsonc'

const j = Jsonic.make().use(Jsonc)

const result = j('{ "name": "app", /* version */ "version": "1.0" }')
// => { name: 'app', version: '1.0' }

Go

Install:

go get github.com/jsonicjs/jsonc/go

Parse:

package main

import (
    "fmt"
    jsonic "github.com/jsonicjs/jsonic/go"
    jsonc "github.com/jsonicjs/jsonc/go"
)

func main() {
    j := jsonic.Make()
    j.Use(jsonc.Jsonc)

    result, err := j.Parse(`{ "name": "app", /* version */ "version": "1.0" }`)
    if err != nil {
        panic(err)
    }
    fmt.Println(result)
    // => map[name:app version:1.0]
}

How-to guides

Allow trailing commas

TypeScript:

const j = Jsonic.make().use(Jsonc, { allowTrailingComma: true })
j('{ "debug": true, "verbose": false, }')
// => { debug: true, verbose: false }

Go:

j := jsonic.Make()
j.Use(jsonc.Jsonc, map[string]any{"allowTrailingComma": true})
result, _ := j.Parse(`{ "debug": true, "verbose": false, }`)

Parse strict JSON (disable comments)

TypeScript:

const j = Jsonic.make().use(Jsonc, { disallowComments: true })
j('{ "foo": /* not allowed */ true }') // throws

Go:

j := jsonic.Make()
j.Use(jsonc.Jsonc, map[string]any{"disallowComments": true})

Handle parse errors

TypeScript — parse errors throw:

try {
  j('{ "bad": }')
} catch (err) {
  console.error(err.message)
}

Go — errors are returned:

if _, err := j.Parse(`{ "bad": }`); err != nil {
    fmt.Println(err)
}

Parse a file

TypeScript:

import { readFileSync } from 'node:fs'
const j = Jsonic.make().use(Jsonc, { allowTrailingComma: true })
const config = j(readFileSync('tsconfig.json', 'utf8'))

Go:

src, _ := os.ReadFile("tsconfig.json")
j := jsonic.Make()
j.Use(jsonc.Jsonc, map[string]any{"allowTrailingComma": true})
config, _ := j.Parse(string(src))

Reference

TypeScript

function Jsonc(jsonic: Jsonic, options?: JsoncOptions): void

type JsoncOptions = {
  allowTrailingComma?: boolean  // default: false
  disallowComments?: boolean    // default: false
}

Register with jsonic.use(Jsonc, options?). After registration, invoke the jsonic instance as a function on a source string; it returns the parsed value or throws on syntax errors.

| Option | Type | Default | Effect | |--------|------|---------|--------| | allowTrailingComma | boolean | false | Permit a trailing comma before } and ] | | disallowComments | boolean | false | Reject // and /* */ comments (strict JSON) |

Go

func Jsonc(j *jsonic.Jsonic, pluginOpts map[string]any) error

Register with j.Use(jsonc.Jsonc) or j.Use(jsonc.Jsonc, opts) where opts is a map[string]any. Parse then returns (any, error)map[string]any for objects, []any for arrays, float64 for numbers, string, bool, or nil.

| Key | Type | Default | Effect | |-----|------|---------|--------| | allowTrailingComma | bool | false | Permit a trailing comma before } and ] | | disallowComments | bool | false | Reject // and /* */ comments (strict JSON) |

JSONC format

JSONC follows RFC 8259 (JSON) with these extensions:

  • Line comments: // to end of line
  • Block comments: /* */ (non-nesting)
  • Trailing commas: optional, in objects and arrays

All other JSON rules apply:

  • Strings must be double-quoted
  • Standard escapes only: \" \\ \/ \b \f \n \r \t \uXXXX
  • Numbers: integer, decimal, scientific notation (no hex, octal, binary)
  • Keywords: true, false, null (case-sensitive)
  • Property names must be double-quoted strings

Conformance notes

The plugin layers JSONC rules on top of jsonic, which is intentionally lenient in some places vs. strict RFC 8259. The test suite runs the nst/JSONTestSuite corpus in strict mode (disallowComments: true) and pins the known-lenient cases in test/jsontestsuite.test.ts (see N_KNOWN_LENIENT). Examples of accepted-but-non-RFC input include numbers with leading zeros and unquoted object keys. Use an RFC-strict parser if byte-perfect RFC 8259 rejection is required.

Acknowledgments

Conformance testing uses third-party corpora under MIT License:

See THIRD_PARTY_NOTICES.md for details.

License

MIT. Copyright (c) 2021-2025 Richard Rodger and contributors.