{"_id":"jsonpack","_rev":"36-f3207250723e175f1f38fb19058e31d4","name":"jsonpack","dist-tags":{"latest":"2.0.0"},"versions":{"1.0.0":{"name":"jsonpack","version":"1.0.0","keywords":["compress","json"],"author":{"name":"Rodrigo González | sapienlab"},"_id":"jsonpack@1.0.0","maintainers":[{"name":"sapienlab","email":"npm@sapienlab.com"}],"homepage":"https://github.com/sapienlab/jsonpack","dist":{"shasum":"6782870a1461fc679877f2f91bcaa1daeae60120","tarball":"https://registry.npmjs.org/jsonpack/-/jsonpack-1.0.0.tgz","integrity":"sha512-beZT540iJn18DpnCyO2BL+tUvlVxL/JZ+LabsJZ4EyqJdYwhT7ePoqpgfrWosr2DGDbE+VyDJKOKYNPD7Yhnyw==","signatures":[{"sig":"MEUCIGUkKLHyxozq+84ZPX1rniWtdbS6AcwNSkdLAIHUl3NTAiEAkzmlm5Pq6DDFiW0rLKJG/OBcNCqCMzCXCTvH0iaMuxc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"icon":"https://raw.github.com/sapienlab/jsonpack/master/icon.png","main":"./main","volo":{"baseDir":"."},"_npmUser":{"name":"sapienlab","email":"npm@sapienlab.com"},"licenses":[{"url":"http://opensource.org/licenses/MIT","type":"MIT"}],"dojoBuild":"package.js","repository":{"url":"https://github.com/sapienlab/jsonpack.git","type":"git"},"_npmVersion":"1.2.0","description":"A compression algorithm for JSON","directories":{}},"1.0.1":{"name":"jsonpack","version":"1.0.1","keywords":["compress","json"],"author":{"name":"Rodrigo González | sapienlab"},"_id":"jsonpack@1.0.1","maintainers":[{"name":"sapienlab","email":"npm@sapienlab.com"}],"homepage":"https://github.com/sapienlab/jsonpack","dist":{"shasum":"ae1e97915021a5ede2749263ea6a48a05b546de6","tarball":"https://registry.npmjs.org/jsonpack/-/jsonpack-1.0.1.tgz","integrity":"sha512-5u/sNfyZ77R58XxvtRfv2Xf32o7Cp70Zks0x0UKHh1PRvJfuYhJ6CCsDbiS4YJ2kQpteI/Lw4P91xl51df5ZHQ==","signatures":[{"sig":"MEQCICpoyuhaJiXKVm30K+7BtC97Aqzw8cbEjvYqTS5o6k2CAiAvM5+53Q/g2sMWJzixsk6ih58cC6KZo6Cfdg+clpcf7g==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"icon":"https://raw.github.com/sapienlab/jsonpack/master/icon.png","main":"./main","volo":{"baseDir":"."},"_from":"https://api.github.com/repos/sapienlab/jsonpack/tarball","scripts":{},"_npmUser":{"name":"sapienlab","email":"hello@sapienlab.com"},"licenses":[{"url":"https://github.com/roro89/jsonpack/blob/master/LICENSE.md","type":"MIT"}],"_resolved":"https://api.github.com/repos/sapienlab/jsonpack/tarball","dojoBuild":"package.js","repository":{"url":"https://github.com/sapienlab/jsonpack.git","type":"git"},"_npmVersion":"1.2.18","description":"A compression algorithm for JSON","directories":{}},"1.1.0":{"name":"jsonpack","version":"1.1.0","keywords":["compress","json"],"author":{"name":"Rodrigo González | sapienlab"},"_id":"jsonpack@1.1.0","maintainers":[{"name":"sapienlab","email":"npm@sapienlab.com"}],"homepage":"https://github.com/sapienlab/jsonpack","dist":{"shasum":"fa135ce9af6075984b850071ae67fb682a143b34","tarball":"https://registry.npmjs.org/jsonpack/-/jsonpack-1.1.0.tgz","integrity":"sha512-xalxDVRpkGB8muyxDK6tO5tmxJGCF+cWw6hHbe6rFabyCY+me8j4k+Sp31/tEIFbW7hyqs568gazAH4Myofecw==","signatures":[{"sig":"MEUCIAqbGhSNto+1IszepLZeut3UKVNIpNvS2+pxfB2TlZExAiEAx1H/nWsIQK5prNMC4+6WCSb9v8NgLB5UatwfzjRxex8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"icon":"https://raw.github.com/sapienlab/jsonpack/master/icon.png","main":"./main","volo":{"baseDir":"."},"_from":"https://github.com/sapienlab/jsonpack/archive/v1.1.0.tar.gz","scripts":{"test":"make test"},"_npmUser":{"name":"sapienlab","email":"hello@sapienlab.com"},"licenses":[{"url":"https://github.com/roro89/jsonpack/blob/master/LICENSE.md","type":"MIT"}],"_resolved":"https://github.com/sapienlab/jsonpack/archive/v1.1.0.tar.gz","dojoBuild":"package.js","repository":{"url":"https://github.com/sapienlab/jsonpack.git","type":"git"},"_npmVersion":"1.2.18","description":"A compression algorithm for JSON","devDependencies":{"mocha":"*","expect.js":"*"},"directories":{}},"1.1.1":{"name":"jsonpack","version":"1.1.1","keywords":["compress","json"],"author":{"name":"Rodrigo González | sapienlab"},"_id":"jsonpack@1.1.1","maintainers":[{"name":"sapienlab","email":"npm@sapienlab.com"}],"homepage":"https://github.com/sapienlab/jsonpack","bugs":{"url":"https://github.com/sapienlab/jsonpack/issues"},"dist":{"shasum":"13333a38a6e13c7539fc73333f2ea3aaa991a3e9","tarball":"https://registry.npmjs.org/jsonpack/-/jsonpack-1.1.1.tgz","integrity":"sha512-4+aYix6a12UATB9OXLszd295mUaUvNHsK+mKzNiemJQvJzgNLViFrJhjTtecqFiRRiBGt2L5t8WkHT58Xx+baQ==","signatures":[{"sig":"MEYCIQDZV3yeRuCLTLGvMnOBMVDpEsh3TI92aP3zNll+rTMjzAIhALetf1CK3W7pYI+6r1i9JOds/JHfpW7W3Wzruazu9ced","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"icon":"https://raw.github.com/sapienlab/jsonpack/master/icon.png","main":"./main","volo":{"baseDir":"."},"_from":".","scripts":{"test":"make test"},"_npmUser":{"name":"sapienlab","email":"hello@sapienlab.com"},"licenses":[{"url":"https://github.com/roro89/jsonpack/blob/master/LICENSE.md","type":"MIT"}],"dojoBuild":"package.js","repository":{"url":"https://github.com/sapienlab/jsonpack.git","type":"git"},"_npmVersion":"1.3.10","description":"A compression algorithm for JSON","devDependencies":{"mocha":"*","expect.js":"*"},"directories":{}},"1.1.2":{"name":"jsonpack","version":"1.1.2","keywords":["compress","json"],"author":{"name":"Rodrigo González | sapienlab"},"_id":"jsonpack@1.1.2","maintainers":[{"name":"sapienlab","email":"npm@sapienlab.com"}],"homepage":"https://github.com/sapienlab/jsonpack","bugs":{"url":"https://github.com/sapienlab/jsonpack/issues"},"dist":{"shasum":"6a9a8fe43374ca551c81838806e3a16bc35c18de","tarball":"https://registry.npmjs.org/jsonpack/-/jsonpack-1.1.2.tgz","integrity":"sha512-VV26f4aug+ZNtstJJT99JEUT/tJzyTa0wW3IYGwVEdgkEG4+84tRpkOXlke99aDcTk7YDu7lAM6A4+WgkVnnsw==","signatures":[{"sig":"MEUCIQD6HblGJiKhaf+5+o6+py+G2QJLPKt5tJkzg+7V0kLjIAIgSchSsESJ+cfZNOGTNJSbpGI9gfRzE+EgWYHNOwx6O/M=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"icon":"https://raw.github.com/sapienlab/jsonpack/master/icon.png","main":"./main","volo":{"baseDir":"."},"_from":"https://github.com/sapienlab/jsonpack/archive/v1.1.2.tar.gz","scripts":{"test":"make test"},"_npmUser":{"name":"sapienlab","email":"hello@sapienlab.com"},"licenses":[{"url":"https://github.com/roro89/jsonpack/blob/master/LICENSE.md","type":"MIT"}],"_resolved":"https://github.com/sapienlab/jsonpack/archive/v1.1.2.tar.gz","dojoBuild":"package.js","repository":{"url":"https://github.com/sapienlab/jsonpack.git","type":"git"},"_npmVersion":"1.3.10","description":"A compression algorithm for JSON","devDependencies":{"mocha":"*","expect.js":"*"},"directories":{}},"1.1.4":{"name":"jsonpack","version":"1.1.4","keywords":["compress","json"],"author":{"name":"Rodrigo González | sapienlab"},"_id":"jsonpack@1.1.4","maintainers":[{"name":"sapienlab","email":"npm@sapienlab.com"},{"name":"roro","email":"rodrigo@sapienlab.com"}],"homepage":"https://github.com/sapienlab/jsonpack","bugs":{"url":"https://github.com/sapienlab/jsonpack/issues"},"dist":{"shasum":"eaf1748c17fcb4cab9237955b2a3bf67cff3b18f","tarball":"https://registry.npmjs.org/jsonpack/-/jsonpack-1.1.4.tgz","integrity":"sha512-jMR7PkERGThff25RcieBueMf+9p906+nwt6t1eJNxnK75W3pwA9W2fSluzoFsDNA4QJN98OuFmdTqMp5HV5ygg==","signatures":[{"sig":"MEUCIByIqXUjrsQMIPYdyghoNC1cR3HRKcNryiAVc6GX7AnTAiEA1ovvJjPk6dSmtWo/MffOMDuITiNSPbv0uUxaq5GpBrY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"icon":"https://raw.github.com/sapienlab/jsonpack/master/icon.png","main":"./main","volo":{"baseDir":"."},"_from":"https://github.com/sapienlab/jsonpack/archive/master.tar.gz","_shasum":"eaf1748c17fcb4cab9237955b2a3bf67cff3b18f","scripts":{"test":"make test"},"_npmUser":{"name":"roro","email":"rodrigo@sapienlab.com"},"licenses":[{"url":"https://github.com/roro89/jsonpack/blob/master/LICENSE.md","type":"MIT"}],"_resolved":"https://github.com/sapienlab/jsonpack/archive/master.tar.gz","dojoBuild":"package.js","repository":{"url":"https://github.com/sapienlab/jsonpack.git","type":"git"},"_npmVersion":"1.4.28","description":"A compression algorithm for JSON","devDependencies":{"mocha":"*","expect.js":"*"},"directories":{}},"1.1.5":{"name":"jsonpack","version":"1.1.5","keywords":["compress","json"],"author":{"name":"Rodrigo González | sapienlab"},"_id":"jsonpack@1.1.5","maintainers":[{"name":"sapienlab","email":"npm@sapienlab.com"},{"name":"roro","email":"rodrigo@sapienlab.com"}],"homepage":"https://github.com/sapienlab/jsonpack","bugs":{"url":"https://github.com/sapienlab/jsonpack/issues"},"dist":{"shasum":"d42b0dcfd91ac58ef3110f96d2c599404c3dc27c","tarball":"https://registry.npmjs.org/jsonpack/-/jsonpack-1.1.5.tgz","integrity":"sha512-d2vwomK605ks7Q+uCpbwGyoIF5j+UZuJjlYcugISBt3CxM+eBo/W6y63yVPIyIvbYON+pvJYsYZjCYbzqJj/xQ==","signatures":[{"sig":"MEQCIFgyOjGjnsBNBba9eqUegrOY25glrHb2xbVC2QWIQ5oxAiBS/UoLcEEzaVUl7PLz/IpiR+gpAn0GPgydPheffJH/xw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"icon":"https://raw.github.com/sapienlab/jsonpack/master/icon.png","main":"./main","volo":{"baseDir":"."},"_from":"https://github.com/sapienlab/jsonpack/archive/master.tar.gz","_shasum":"d42b0dcfd91ac58ef3110f96d2c599404c3dc27c","scripts":{"test":"make test"},"_npmUser":{"name":"sapienlab","email":"hello@sapienlab.com"},"licenses":[{"url":"https://github.com/roro89/jsonpack/blob/master/LICENSE.md","type":"MIT"}],"_resolved":"https://github.com/sapienlab/jsonpack/archive/master.tar.gz","dojoBuild":"package.js","repository":{"url":"git+https://github.com/sapienlab/jsonpack.git","type":"git"},"_npmVersion":"2.14.2","description":"A compression algorithm for JSON","_nodeVersion":"4.0.0","devDependencies":{"mocha":"*","expect.js":"*"},"_npmOperationalInternal":{"tmp":"tmp/jsonpack-1.1.5.tgz_1461171819796_0.5591822520364076","host":"packages-16-east.internal.npmjs.com"},"directories":{}},"2.0.0":{"name":"jsonpack","version":"2.0.0","description":"A compression algorithm for JSON","author":{"name":"Rodrigo González","email":"rodrigo@sasud.com"},"license":"MIT","homepage":"https://github.com/rgcl/jsonpack","repository":{"type":"git","url":"git+https://github.com/rgcl/jsonpack.git"},"keywords":["compress","json","pack","unpack"],"engines":{"node":">=14"},"main":"./index.js","module":"./index.mjs","types":"./index.d.ts","exports":{".":{"import":"./index.mjs","require":"./index.js","types":"./index.d.ts"}},"scripts":{"test":"mocha test/*.js"},"devDependencies":{"mocha":"^10.4.0","chai":"^4.4.1"},"gitHead":"d42dc4b9325610103df9634a4d46bc79205dd953","_id":"jsonpack@2.0.0","bugs":{"url":"https://github.com/rgcl/jsonpack/issues"},"_nodeVersion":"26.3.0","_npmVersion":"11.16.0","dist":{"integrity":"sha512-71yTAiOnqHDrCQ3vifQuTmOxXagfrAbQ/SmMWE0yHz/vbP/JuZoMtohgQdwxpko3DmODd4M9gbe+oFgsybUn2g==","shasum":"240b448936a9e0c92e82386bfa8695e327b10c75","tarball":"https://registry.npmjs.org/jsonpack/-/jsonpack-2.0.0.tgz","fileCount":6,"unpackedSize":16993,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCJ9pspdC8kLDEjYDecX7trMeeSSRj1P/XxaduNJTuabAIhAIPlLCl06k2o8Reyv1EFZkgbnFSHLVxdl5vK5CadWSYt"}]},"_npmUser":{"name":"roro","email":"r.gnzlz.cstll@gmail.com"},"directories":{},"maintainers":[{"name":"sapienlab","email":"hello@sapienlab.com"},{"name":"roro","email":"r.gnzlz.cstll@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/jsonpack_2.0.0_1781933988860_0.2303331461865532"},"_hasShrinkwrap":false}},"time":{"created":"2013-03-22T13:43:12.814Z","modified":"2026-06-20T05:39:49.123Z","1.0.0":"2013-03-22T13:43:15.049Z","1.0.1":"2014-03-09T02:11:56.709Z","1.1.0":"2014-07-08T05:52:30.607Z","1.1.1":"2014-08-09T06:11:37.587Z","1.1.2":"2014-09-20T19:15:59.227Z","1.1.4":"2015-01-09T21:03:15.582Z","1.1.5":"2016-04-20T17:03:41.968Z","2.0.0":"2026-06-20T05:39:49.005Z"},"bugs":{"url":"https://github.com/rgcl/jsonpack/issues"},"author":{"name":"Rodrigo González","email":"rodrigo@sasud.com"},"homepage":"https://github.com/rgcl/jsonpack","keywords":["compress","json","pack","unpack"],"repository":{"type":"git","url":"git+https://github.com/rgcl/jsonpack.git"},"description":"A compression algorithm for JSON","maintainers":[{"name":"sapienlab","email":"hello@sapienlab.com"},{"name":"roro","email":"r.gnzlz.cstll@gmail.com"}],"readme":"# jsonpack\n\n[![Test](https://github.com/rgcl/jsonpack/actions/workflows/test.yml/badge.svg)](https://github.com/rgcl/jsonpack/actions/workflows/test.yml)\n[![npm](https://img.shields.io/npm/v/jsonpack)](https://www.npmjs.com/package/jsonpack)\n\nA URL-safe JSON serializer. Produces compact ASCII output usable directly in URLs and `localStorage` — no base64, no binary, no extra encoding step.\n\n## Installation\n\n```bash\nnpm install jsonpack\n```\n\n## Usage\n\n**CommonJS**\n```js\nconst { pack, unpack } = require('jsonpack');\n```\n\n**ESM**\n```js\nimport { pack, unpack } from 'jsonpack';\n```\n\n**Example**\n```js\nconst { pack, unpack } = require('jsonpack');\n\nconst data = {\n    type: 'FeatureCollection',\n    features: [\n        { type: 'Feature', geometry: { type: 'Point', coordinates: [-73.98, 40.74] }, properties: { name: 'A' } },\n        { type: 'Feature', geometry: { type: 'Point', coordinates: [-73.99, 40.75] }, properties: { name: 'B' } },\n        // ... hundreds more\n    ]\n};\n\nconst packed = pack(data);\n// repeated keys like \"type\", \"Feature\", \"geometry\", \"Point\", \"coordinates\"\n// are stored once in a dictionary and referenced by index\n\nconst restored = unpack(packed);\n```\n\n## API\n\n### `pack(json, options?)`\n\nSerializes a JSON value into a compact URL-safe string.\n\n- `json` — any JSON-serializable value, or a JSON string\n- `options.verbose` — log each step to console (default: `false`)\n- `options.debug` — return internal representation instead of string (default: `false`)\n\n`Date` objects are preserved: `unpack(pack(date))` returns a `Date` instance, not a string.\n\nReturns a `string`.\n\n### `unpack(packed, options?)`\n\nRestores the original value from a packed string.\n\n- `packed` — string produced by `pack()`\n- `options.verbose` — log each step to console (default: `false`)\n\nReturns the original value.\n\n---\n\n## Why jsonpack\n\nThe standard way to embed JSON in a URL or `localStorage` is:\n\n```js\nencodeURIComponent(JSON.stringify(data))\n```\n\nIt works, but it *expands* your data — `{`, `\"`, `:` become `%7B`, `%22`, `%3A`. A typical API response grows to **140–170% of its original size**.\n\nThe alternative with the best compression, [lz-string](https://github.com/pieroxy/lz-string), shrinks data dramatically but decodes **4–6× slower**.\n\njsonpack sits in between: **< 7 KB minified, zero dependencies** (no transitive dependencies either).\n\n### Benchmark\n\nMeasured across 8 real-world datasets (GeoJSON, e-commerce, API responses, deeply nested structures):\n\n![URL-safe JSON serializers: compression vs speed](charts/01-scatter-compression-vs-speed.png)\n\n| | encodeURI(JSON) | **jsonpack** | lz-string (URI) |\n|---|:---:|:---:|:---:|\n| Avg output size | 152% of original | **68% of original** | 39% of original |\n| Avg unpack speed | 262 MB/s | **171 MB/s** | 41 MB/s |\n| Zero dependencies | ✓ | ✓ | ✓ |\n| URL-safe output | ✓ | ✓ | ✓ |\n\n#### Compression by dataset\n\n![Compression ratio by dataset](charts/02-ratio-per-dataset.png)\n\n#### Unpack speed by dataset\n\n![Unpack speed by dataset](charts/03-unpack-speed-per-dataset.png)\n\nFull benchmark methodology and raw results: [rgcl/jsonpack-benchmark](https://github.com/rgcl/jsonpack-benchmark)\n\n### When to use jsonpack\n\n**Use jsonpack when:**\n- You need to store JSON in a URL query string or `localStorage`\n- Output size matters (jsonpack produces ~55% less data than `encodeURIComponent`)\n- Fast decoding matters (jsonpack decodes 4× faster than lz-string)\n- You can't afford to grow your bundle\n\n**Use lz-string instead when** output size is the only constraint and decoding speed doesn't matter.\n\n**Use `encodeURIComponent` when** the data is small, changes rarely, or you want zero abstraction.\n\n### How it works\n\njsonpack builds a dictionary of all unique values (strings, integers, floats, dates) in the JSON and replaces them with base-36 indices. The result is a flat, ASCII-only string. Repeated keys and values — common in structured data like API responses and GeoJSON — are stored once and referenced everywhere.\n\n`Date` objects are stored as ISO 8601 strings in the dictionary and marked with a special token in the structure, so `unpack` can restore them as `Date` instances. This is one area where jsonpack goes beyond what `JSON.parse(JSON.stringify())` offers natively.\n\n---\n\n## Notes\n\n- Pack and unpack are synchronous. For large payloads in a browser, run them in a [Web Worker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API).\n- Requires Node.js ≥ 14.\n- The packed format is not binary-compatible with other JSON compression libraries.\n\n## Licence\n\nMIT © 2013 Rodrigo González, SASUD\n","readmeFilename":"README.md","users":{"denji":true,"sapienlab":true,"hengkiardo":true,"monolithed":true,"scottfreecode":true,"becomethegamer":true,"andrew.medvedev":true},"license":"MIT"}