# uniku

> Minimal, tree-shakeable unique ID generators for every JavaScript runtime

Latest version **0.6.0** (published 2026-08-13) · MIT license · 0 weekly downloads

## Install

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

## Health

**Score 65/100 (B)** — status: active.

Positive: esm support; no vulnerabilities; has provenance; recently updated; high maintenance score.

Warnings: low downloads; no types; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.6.0 |
| Published | 2026-08-13 |
| First published | 2026-02-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM |
| Node | >=20.19.0 |
| Dependencies | 1 |
| Unpacked size | 350.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 18 |
| Author | Alberto Schiabel |
| Maintainers | jkomyno |
| Keywords | uuid, uuidv4, uuidv7, ulid, typeid, cuid2, nanoid, ksuid, objectid, xid, mongodb, tsid, snowflake, unique, id, identifier, random, rfc4122, rfc9562, esm, typescript, tree-shakeable, edge, cloudflare-workers, bun, webcrypto |

## Links

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

## Dependencies (1)

- [@noble/hashes](https://npm.io/package/@noble/hashes.md) ^2.2.0

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 0.6.0 (latest) — 2026-08-13
- 1.0.0-rc.0 (rc) — 2026-07-27
- 0.5.0 — 2026-07-27
- 0.4.3 — 2026-07-15
- 0.4.2 — 2026-07-15
- 0.4.1 — 2026-07-14
- 0.4.0 — 2026-07-13
- 0.3.2 — 2026-07-13
- 0.3.1 — 2026-07-12
- 0.3.0 — 2026-07-10
- 0.2.0 — 2026-07-07
- 0.1.0 — 2026-07-05
- 0.0.13 — 2026-07-04
- 0.0.12 — 2026-02-08
- 0.0.11 — 2026-02-08
- … 8 more at https://npm.io/package/uniku/versions

## README

# uniku

[![npm version](https://img.shields.io/npm/v/uniku.svg)](https://www.npmjs.com/package/uniku)
[![npm downloads](https://img.shields.io/npm/dm/uniku.svg)](https://npmjs.com/package/uniku)
[![CI](https://github.com/jkomyno/uniku/actions/workflows/ci.yaml/badge.svg?branch=main)](https://github.com/jkomyno/uniku/actions/workflows/ci.yaml)
[![Documentation](https://img.shields.io/badge/docs-read-5b5bd6.svg)](https://jkomyno.github.io/uniku/)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)

Ten ID strategies behind one consistent, type-safe API. The fastest implementation of each in our [current CI benchmark](https://jkomyno.github.io/uniku/docs/guides/performance/).

> **uniku** */uˈniːku/*: Maltese for "unique"

[Documentation](https://jkomyno.github.io/uniku/) · [Getting started](https://jkomyno.github.io/uniku/docs/getting-started/) · [Choosing an ID](https://jkomyno.github.io/uniku/docs/guides/choosing-an-id/) · [API reference](https://jkomyno.github.io/uniku/docs/reference/entry-points/) · [CLI](https://jkomyno.github.io/uniku/docs/cli/)

```ts
import { uuidv7 } from 'uniku/uuid/v7'

const id = uuidv7()
// => "018e5e5c-7c8a-7000-8000-000000000000"
```

## Why `uniku`?

- **Fastest across the benchmark suite.** Every strategy beats its dedicated npm alternative in the current isolated-process CI benchmark, from 1.2× for UUID v4 and ObjectID to 116× for ULID.
- **Ten strategies, one type-safe API.** UUID v4/v7, ULID, TypeID, CUID v2, Nanoid, KSUID, ObjectID, XID, and TSID each expose a callable generator with matching typed helpers.
- **Portable by default.** Runs on Node.js, Bun, Deno, browsers, edge runtimes, and Cloudflare Workers using `globalThis.crypto`.
- **Tree-shakeable entry points.** Import only the generator you use; the package root is intentionally not exported.
- **Useful at system boundaries.** Validate unknown input, convert canonical binary formats to bytes, or write directly into a caller-owned buffer.
- **Small dependency surface.** CUID v2 is the only generator with a runtime dependency (`@noble/hashes`).

## Install

```sh
npm install uniku
```

The [getting-started guide](https://jkomyno.github.io/uniku/docs/getting-started/) also covers pnpm, Bun, and Deno.

## Public API at a glance

Each module exports a callable generator with attached helpers. The most common public API looks like this:

```ts
import { uuidv7 } from 'uniku/uuid/v7'

const id = uuidv7()
// e.g. '019f5732-0342-75f9-9efd-fc3c1f8da7fd'

uuidv7.isValid(id)
// true

const bytes = uuidv7.toBytes(id)
// Uint8Array(16)

uuidv7.fromBytes(bytes)
// the same value as `id`

uuidv7.timestamp(id)
// e.g. 1783874323266

uuidv7.NIL
// '00000000-0000-0000-0000-000000000000'

uuidv7.MAX
// 'ffffffff-ffff-ffff-ffff-ffffffffffff'
```

Binary modules can also write directly into a caller-owned buffer:

```ts
const destination = new Uint8Array(24)
const result = uuidv7(undefined, destination, 8)
// Uint8Array(24), with UUID bytes at offsets 8 through 23

result === destination
// true
```

### How modules differ

| Modules | Public API |
| --- | --- |
| `uuid/v7`, `ulid`, `ksuid`, `objectid`, `xid` | Callable, buffer write, `toBytes()`, `fromBytes()`, `timestamp()`, `isValid()`, `NIL`, `MAX` |
| `uuid/v4` | Callable, buffer write, `toBytes()`, `fromBytes()`, `isValid()`, `NIL`, `MAX` |
| `typeid` | Prefix-first callable, buffer write, `toBytes()`, `fromBytes()`, `toUuid()`, `fromUuid()`, `timestamp()`, `prefix()`, `suffix()`, `isValid()` |
| `tsid` | `bigint` primary value, buffer write, `toBytes()`, `fromBytes()`, `toString()`, `fromString()`, `timestamp()`, `isValid()`, `NIL`, `MAX` |
| `cuid/v2`, `nanoid` | Callable and `isValid()` only |

Open the [generator reference](https://jkomyno.github.io/uniku/docs/reference/entry-points/) for complete signatures, options, constants, and examples.

There are no barrel exports:

```ts
import { uuidv4 } from 'uniku/uuid/v4'
import { ulid } from 'uniku/ulid'
import { typeid } from 'uniku/typeid'
import { cuidv2 } from 'uniku/cuid/v2'
import { nanoid } from 'uniku/nanoid'
import { ksuid } from 'uniku/ksuid'
import { objectid } from 'uniku/objectid'
import { xid } from 'uniku/xid'
import { tsid } from 'uniku/tsid'
```

## Choose an ID

| Situation | Start with | Why |
| --- | --- | --- |
| Database primary keys | UUID v7 or ULID | Time-ordered values improve index locality |
| Public API resources | TypeID | UUID v7 with a readable, domain-specific prefix |
| Short URLs and invite codes | Nanoid | Compact and URL-safe |
| Values that should resist enumeration | CUID v2 | Non-sequential and secure |
| MongoDB `_id` compatibility | ObjectID | Matches MongoDB's 12-byte ObjectID format |
| Go rs/xid compatibility | XID | Matches rs/xid's text and binary representation |
| Native `BIGINT` storage | TSID | A sortable 64-bit integer rather than a UUID-shaped string |
| Broad standards compatibility | UUID v4 | The conventional random UUID format |

The [choosing guide](https://jkomyno.github.io/uniku/docs/guides/choosing-an-id/) covers ordering, timestamp leakage, storage boundaries, and format-specific trade-offs.

## Documentation

- [Getting started](https://jkomyno.github.io/uniku/docs/getting-started/): installation, direct imports, validation, and byte helpers
- [Generator reference](https://jkomyno.github.io/uniku/docs/reference/entry-points/): generated from the public TypeScript signatures and JSDoc
- [Migration guide](https://jkomyno.github.io/uniku/docs/migration/from-other-libraries/): move from `uuid`, `nanoid`, `ulid`, CUID2, KSUID, BSON, TSID, or XID libraries
- [Performance and bundle size](https://jkomyno.github.io/uniku/docs/guides/performance/): benchmark methodology, current measurements, and reproduction commands
- [Stability contract](https://github.com/jkomyno/uniku/blob/main/docs/STABILITY.md): the entry points and compatibility policy planned for `uniku@1.0.0`

## CLI companion

`@uniku/cli` generates, validates, and inspects IDs from a terminal or shell pipeline. Install the current standalone binary:

```sh
curl -fsSL https://raw.githubusercontent.com/jkomyno/uniku/main/install.sh | sh

uniku uuid -v 7
uniku validate 018e5e5c-7c8a-7000-8000-000000000000
uniku inspect 018e5e5c-7c8a-7000-8000-000000000000
```

See the [CLI documentation](https://jkomyno.github.io/uniku/docs/cli/) for package-manager installs and the complete command reference.

## Contributing

See [CONTRIBUTING.md](https://github.com/jkomyno/uniku/blob/main/CONTRIBUTING.md) for the development workflow, tests, benchmarks, and preview releases.

## License

MIT © [Alberto Schiabel](https://github.com/jkomyno)

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