# zipnum

> Number to ancii or utf string packing and vise-versa.

Latest version **2.1.3** (published 2026-02-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install zipnum
pnpm add zipnum
yarn add zipnum
bun add zipnum
```

## Health

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

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

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 2.1.3 |
| Published | 2026-02-20 |
| First published | 2023-01-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Dependencies | 1 |
| Unpacked size | 22.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Michael houd1ni Akiliev |
| Maintainers | houd1ni |
| Keywords | serialization, deserialization, compression, deflate, zip, number, pure, strongly-typed, typescript, d.ts |

## Links

- npm: https://www.npmjs.com/package/zipnum
- Repository: https://github.com/houd1ni/zipnum
- Homepage: https://github.com/houd1ni/zipnum/
- Issues: https://github.com/houd1ni/zipnum/issues
- npm.io page: https://npm.io/package/zipnum

## Dependencies (1)

- [pepka](https://npm.io/package/pepka.md) ^1.6.23

## Alternatives

- [lodash.startswith](https://npm.io/package/lodash.startswith.md) — 769.7K weekly downloads
- [@tarojs/service](https://npm.io/package/@tarojs/service.md) — 33.9K weekly downloads
- [io.extendreality.tilia.indicators.spatialtargets.unity](https://npm.io/package/io.extendreality.tilia.indicators.spatialtargets.unity.md) — 131 weekly downloads
- [@rtarojs/taro](https://npm.io/package/@rtarojs/taro.md) — 90 weekly downloads
- [node-branch-io](https://npm.io/package/node-branch-io.md) — 50 weekly downloads

## Recent versions

- 2.1.3 (latest) — 2026-02-20
- 2.1.2 — 2026-02-20
- 2.1.1 — 2026-02-20
- 2.1.0 — 2026-02-20
- 2.0.1 — 2026-01-18
- 2.0.0 — 2025-02-04
- 1.0.0 — 2023-01-17

## README

# zipnum

This is a quick number to string packer that works like 'number to hex' convertions but with arbitrary base/radix and alphabets, that defaults to 0...z...Z with base 62 that allows to safely pack large numbers to small strings.
Originally written for [WebsocketPromisify lib](https://github.com/houd1ni/WebsocketPromisify)

This is needed when you want to put numbers into strings to use all encoding bits instead of leaving most of them as copies:
'564654987' vs 'MnoIF' for example. With large quantities of them being sent via network or saved into storage, it has difference.

The library is written in Typescript and has js-doc annotations.

## Performance
According to jsben.ch tests on intel 12100 / DDR4-3200-16 @ firefox107:
  - zipping of (each time) randomly generated numbers from 0 to 1e20 is around 6.5Mops/sec (850Kops with random generation).
  - unzipping numbers of 5(big) and 10(extremely large) chars (that each loop regenerated) to numbers is like 34 Mops/sec (930kops with string generation)

## API with examples

```typescript
// Using class constructor instead of direct imports are new to ver2 to avoid settings interference.

// zipnum.ts, utils.ts or whatever:
import { Zipnum } from 'zipnum'

const zipnum = new Zipnum() // or new Zipnum(abc)

// importing and calling setABC is fully optional,
//   because it is already called with 62-length alphabet under the hood and ready.
// But you can call it with large utf-8 sequences to compress stronger.
// Argument is a new alphabet. Shortcut is to call constructor with this: new Zipnum(abc).
zipnum.setABC('0123456789abcdefghijklmnopqrstuvwxyz')
export {zipnum}

// anythingelse.ts:
import {zipnum} from './zipnum' // that zipnum.ts, utils.ts or whatever (see above).

const packedString0 = zipnum.zip(0) // -> '0'
const packedString1 = zipnum.zip(10) // -> 'a'
const packedString2 = zipnum.zip(564654987) // -> 'aq9rtm'

zipnum.setABC('abcdefghijklmnopqrstuvwxyz!@#$%^&*()_')
const packedString3 = zipnum.zip(564654987) // -> 'jmgsu@'
const unpackedNumber = zipnum.unzip(packedString3) // -> 564654987

```

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