Registry / storage / json-minifier

json-minifier

JSON →
library0.0.3jsnpmunverified

A two-way JSON minifier that compresses JSON by replacing long property keys with short aliases defined in a mapping object. Version 0.0.3 is the latest and only release. It reduces data transfer size and can act as an obfuscator. Unlike gzip compression, this approach is deterministic and preserves the original structure after unminifying. Works on Node.js and in browsers with a custom snippet. No updates since 2015, likely in maintenance mode.

npm install json-minifier
INSTALL
IMPORT
SIG · JSON-MINIFIER
J
json-minifier
storagejavascriptv0.0.3
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
const minifier = require('json-minifier')(specs)
import minifier from 'json-minifier'; // no default export; factory function
The package exports a factory function that takes a mapping object and returns an object with minify/unminify methods.
minify
const minifier = require('json-minifier')(specs); const out = minifier.minify(json)
const { minify } = require('json-minifier'); // not exported as named
minify is a method on the object returned by the factory, not a named export.
unminify
const minifier = require('json-minifier')(specs); const original = minifier.unminify(compressedJson)
const unminify = require('json-minifier').unminify; // no such export
Same as minify, unminify is a method on the returned object.

Shows how to create a minifier with a mapping and minify/unminify a simple JSON object.

const specs = { 'longPropertyName1': 'a', 'longPropertyName2': 'b' }; const minifier = require('json-minifier')(specs); const original = { longPropertyName1: 'value1', longPropertyName2: 42 }; const compressed = minifier.minify(original); console.log(compressed); // { a: 'value1', b: 42 } const restored = minifier.unminify(compressed); console.log(restored); // { longPropertyName1: 'value1', longPropertyName2: 42 }
Debug
Known issues
gotchaMapping object values must be unique and short strings to avoid collisions.
fix
Ensure no two keys map to the same short alias, and aliases are valid JSON keys.
affects: 0.0.3
gotchaDoes not handle nested objects automatically if the mapping is only for top-level keys.
fix
Provide a mapping that covers all nested property paths, or recursively apply minification.
affects: 0.0.3
deprecatedPackage has not been updated since 2015; no TypeScript or modern ESM support.
fix
Consider alternatives like json-bignum or use a custom implementation based on the browser snippet.
affects: >=0.0.0
gotchaThe 'unzip' browser snippet requires globally exposed reverseJsonFilters array.
fix
Ensure reverseJsonFilters is defined and maps short aliases back to original keys.
affects: 0.0.3
Errors
Common errors & fixes
TypeError: minifier.minify is not a function
Forgetting to invoke the factory function with specs; minifier is the factory, not the minifier object.
fix
Call require('json-minifier')(specs) to get the minifier object.
Cannot find module 'json-minifier'
Package not installed or imported incorrectly in non-Node environment.
fix
Run npm install json-minifier and require correctly. In browser, use the provided snippet instead.
Upgrade
Version history
0.0.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
29 hits · last 30 days
node
28
Resources
json-minifier — npm install json-minifier · libregistry