JSSC (JavaScript String Compressor) is an open-source, lossless string compression algorithm designed specifically for JavaScript.
It operates directly on JavaScript strings (UTF-16) and produces compressed data that is also a valid JavaScript string.
JSSC is distributed as a UMD module and can be used in browsers, Node.js, Deno, and other JavaScript environments.
- ✨ Lossless compression
- 🗜️ High compression ratios
- up to 8:1 for numeric data
- strong results for repetitive and structured text
- 🌍 Multilingual support
- English, Russian, Japanese, Chinese, Hindi, Bengali, and more
- 📦 JSON support
- JSON is converted to JUSTC before compression
- ⚙️ String → String
- no binary buffers
- no external metadata
- all required information is embedded into the compressed string itself
- 🧠 Self-validating compression
- every compression mode is verified by decompression before being accepted
- 🔁 Recursive compression
- 📜 TypeScript definitions included
- 🌐 UMD build for browsers and static websites
Reasons:
- The first 16 bits (header layout) were slightly redesigned
- New compression modes were added
- Character encoding tables were extended
JSSC operates on JavaScript UTF-16 code units, not on UTF-8 bytes.
This means:
- Any character representable in a JavaScript string is supported
- Compression works at the UTF-16 level
- One JavaScript character = 16 bits
- Binary data must be converted to strings before compression
The project is called JSSC (JavaScript String Compressor).
The npm package is published under the name strc, because the name jssc is already occupied on npm by an unrelated Java-based package.
Both names refer to the same project.
Install via npm
npm i strc
The npm package name is
strc, but the library itself is JSSC.
Or you can use it on your website by inserting the following HTML script tags.
<script src="https://unpkg.com/justc"></script>
<script src="https://unpkg.com/strc"></script>const { compress, decompress } = require('strc');
const example = await compress("Hello, world!");
await decompress(example);import { compress, decompress } from 'strc';
const example = await compress("Hello, world!");
await decompress(example);import JSSC from 'https://jssc.js.org/jssc.min.js';
const example = await JSSC.compress("Hello, world!");
await JSSC.decompress(example);When using the UMD build via CDN, the library is exposed globally as JSSC.
<script src="https://unpkg.com/justc"></script>
<script src="https://unpkg.com/strc"></script>const compressed = await JSSC.compress("Hello, world!");
const decompressed = await JSSC.decompress(compressed);Compresses the input and returns a compressed JavaScript string.
Decompresses a previously compressed string/object/integer.
JSSC depends on:
JUSTC by JustStudio.
For .min.js, I use UglifyJS by Mihai Bazon.
npm i uglify-jsuglifyjs index.js -c -m "reserved=['compress','decompress']" -o index.min.js