Registry / devops / jwccminify

jwccminify

JSON →
library1.0.0jsnpmunverified

A lightweight JSON minifier that removes whitespace and comments from JWCC (JSON with Commas and Comments) or HuJSON (Human JSON). Version 1.0.0 is the current stable release. It supports single-line (//) and multi-line (/* */) comments, removes trailing commas, and strips all whitespace. It is fault-tolerant (handles invalid JSON), has zero dependencies, and uses no regular expressions. Compared to alternatives, it is minimal and strictly focused on JWCC/HuJSON input.

npm install jwccminify
INSTALL
IMPORT
SIG · JWCCMINIFY
J
jwccminify
devopsjavascriptv1.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default (jwccminify)
import jwccminify from 'jwccminify';
const jwccminify = require('jwccminify');
Package ships ESM and CJS; both default and named exports work.
named jwccminify
import { jwccminify } from 'jwccminify';
Available as named export since v1.0.0.
named jwccstrip
import { jwccstrip } from 'jwccminify';
Second function that strips comments and commas but preserves whitespace around them.
UMD window global
const { jwccminify, jwccstrip } = JwccMinify;
const { jwccminify, jwccstrip } = window;
UMD build sets global variable 'JwccMinify' (capital J).

Demonstrates usage of jwccminify and jwccstrip to minify or strip comments from JWCC/HuJSON.

import jwccminify from 'jwccminify'; const input = `{ "name": "example", // This is a comment "value": 123, /* Multi-line comment */ }`; const output = jwccminify(input); console.log(output); // {"name":"example","value":123} // Also use jwccstrip to remove comments but keep whitespace import { jwccstrip } from 'jwccminify'; const stripped = jwccstrip(input); console.log(stripped); // { // "name": "example", // "value": 123 // }
Debug
Known issues
gotchajwccminify is not a full JSON validator; it will still produce output for invalid JSON by attempting to strip comments and commas, which may yield unexpected results.
fix
Validate JSON separately (e.g., with JSON.parse) if you need to ensure validity.
affects: >=1.0.0
gotchajwccstrip replaces comments and trailing commas with whitespace, not removes them; the output may still contain spaces and newlines.
fix
Use jwccminify instead of jwccstrip if you want to fully remove whitespace.
affects: >=1.0.0
gotchaThe package does not support inline block comments within string values; JSON strings containing /* or // may be incorrectly treated as comments.
fix
Avoid input where string values contain comment markers.
affects: >=1.0.0
deprecatedThe UMD global is named JwccMinify (capital J). Developers often expect lowercase or 'jwccminify'.
fix
Access via window.JwccMinify or import from the ES module.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'jwccminify'
Package not installed or import path incorrect.
fix
npm install jwccminify
TypeError: jwccminify is not a function
Using default import but the module exposes only named exports in some bundlers.
fix
Use import { jwccminify } from 'jwccminify'; or check bundler config.
JwccMinify is not defined
Using UMD script tag without loading the file or referencing wrong global name.
fix
Ensure <script src="./dist/jwccminify.umd.js"> is included and use window.JwccMinify.
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
3 hits · last 30 days
node
2
Resources
jwccminify — npm install jwccminify · libregistry