# @remusao/smaz

> Compress strings using custom codebooks

Latest version **2.2.0** (published 2025-05-16) · MPL-2.0 license · 0 weekly downloads

## Install

```sh
npm install @remusao/smaz
pnpm add @remusao/smaz
yarn add @remusao/smaz
bun add @remusao/smaz
```

## Health

**Score 50/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 2.2.0 |
| Published | 2025-05-16 |
| First published | 2020-02-03 |
| Weekly downloads | 0 |
| License | MPL-2.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 29.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 15 |
| Author | Rémi Berson <remi@cliqz.com> |
| Maintainers | remusao |

## Links

- npm: https://www.npmjs.com/package/@remusao/smaz
- Repository: https://github.com/remusao/mono
- Homepage: https://github.com/remusao/mono#readme
- Issues: https://github.com/remusao/mono/issues
- npm.io page: https://npm.io/package/@remusao/smaz

## Dependencies (2)

- [@remusao/smaz-compress](https://npm.io/package/@remusao/smaz-compress.md) ^2.2.0
- [@remusao/smaz-decompress](https://npm.io/package/@remusao/smaz-decompress.md) ^2.2.0

## Recent versions

- 2.2.0 (latest) — 2025-05-16
- 1.9.1-canary.309.bb92957ae635c786e8798fd12cc9d8a0213d624f.0 (canary) — 2020-11-03
- 2.1.0 — 2025-04-10
- 2.0.0 — 2025-04-07
- 1.10.0 — 2024-07-11
- 1.9.1 — 2020-11-03
- 1.9.1-canary.307.a8b715240fbe1ea8f6c58b1e778de472a237b6c3.0 — 2020-11-03
- 1.9.1-canary.306.92331cfe30132d83f557c212e90b7870a054712c.0 — 2020-11-02
- 1.9.1-canary.305.9461d0d8204f319a81ae7ecc2b873c3deac2bb3b.0 — 2020-11-02
- 1.9.1-canary.304.00af04df77e6c80e2417971e89e371604f318e4a.0 — 2020-11-01
- 1.9.1-canary.303.d5405a9efbd58804427096689a1e8df212ec2458.0 — 2020-10-30
- 1.9.1-canary.302.28c36e01aed2a0381b38131546b5713389a1d53c.0 — 2020-10-29
- 1.9.1-canary.301.dee75a3ec5e278abf0bec136bf0edda997a4775a.0 — 2020-10-29
- 1.9.1-canary.300.cf6720273d182293ff3e38d696a4127b4d5ef888.0 — 2020-10-28
- 1.9.1-canary.299.b9646709bc95e7c9eb5d634a596746ddcbb42030.0 — 2020-10-27
- … 129 more at https://npm.io/package/@remusao/smaz/versions

## README

# `@remusao/smaz`

> Compress strings using custom codebooks

A port of the [smaz](https://github.com/antirez/smaz) small string compression library to JavaScript.

From the original library:

> Smaz is a simple compression library suitable for compressing very short
> strings. General purpose compression libraries will build the state needed
> for compressing data dynamically, in order to be able to compress every kind
> of data. This is a very good idea, but not for a specific problem: compressing
> small strings will not work.
>
> Smaz instead is not good for compressing general purpose data, but can compress
> text by 40-50% in the average case (works better with English), and is able to
> perform a bit of compression for HTML and urls as well. The important point is
> that Smaz is able to compress even strings of two or three bytes!
>
> For example the string "the" is compressed into a single byte.
>
> To compare this with other libraries, think that like zlib will
> usually not be able to compress text shorter than 100 bytes.

## Usage

```javascript
const { compress, decompress } = require('@remusao/smaz');

const compressed = compress('foobar');
console.log(decompress(compressed));
```

With encoding:
```javascript
const { compress, decompressRaw } = require('@remusao/smaz');

const compressed = compress(new TextEncoder().encode('foobar'));
console.log(new TextDecoder('utf8').decode(decompressRaw(compressed)));
```

---
_Source: https://npm.io/package/@remusao/smaz · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
