npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@lacspace/id

v1.1.2

Published

Every ID kind you need — UUID v4/v7, ULID, cuid2, Snowflake, Nano-ID, base62/base58 and Stripe-style prefixed ids. Custom alphabets with unbiased sampling, time-sortable + decodeTime. Cryptographically random (Web Crypto), zero-dependency, isomorphic.

Downloads

148

Readme

@lacspace/id

Unique IDs done right — UUID v4, time-sortable UUID v7, Nano-ID-style & short codes.

npm version minzipped types license

Every ID kind you actually need, in one tiny package — including UUID v7, the time-sortable UUID that makes a fantastic database primary key. Cryptographically random (Web Crypto), monotonic within a millisecond, zero-dependency.

  • 🆔 uuidv4() — classic random UUID
  • ⏱️ uuidv7() — time-sortable UUID (great index-friendly primary key)
  • 🔤 nanoid() / shortId() — URL-safe random strings
  • 🏷️ id("user") — prefixed ids like user_9f8c…

✨ New in 1.1.0

More formats and building blocks, all zero-dep and CSPRNG-backed:

  • 🧭 ulid() — Crockford base32, time-sortable & monotonic (26 chars)
  • 🧵 cuid2() — collision-resistant, letter-leading id
  • ❄️ snowflakeFactory() — 64-bit sortable id with injectable epoch / machine id / clock
  • 🔡 customId({ alphabet, size }) — any alphabet, unbiased (rejection sampling) + ALPHABETS presets + base62Id() / base58Id()
  • 🏷️ prefixedId("user") / parsePrefixedId() — Stripe-style typed ids, round-trippable
  • 🕒 decodeTime(id) — read the timestamp back out of a ULID or UUID v7
  • ✅ isUlid / isCuid2 / isSnowflake validators
import { ulid, cuid2, snowflakeFactory, customId, prefixedId, decodeTime, ALPHABETS } from "@lacspace/id";

ulid();                                   // "01JR8Z3C2F6ABM7Q9K…"  ← sorts by time
cuid2();                                  // "k3f9x2q7z1m8..."
customId({ alphabet: ALPHABETS.base58, size: 12 });  // unbiased over any alphabet
prefixedId("user");                       // "user_9f8c1a3e…"  → parsePrefixedId() splits it back
decodeTime(ulid());                       // 1757… (ms since epoch)

const nextId = snowflakeFactory({ machineId: 7 });
nextId();                                 // "72057594037…"  (64-bit, JSON-safe string)

What's new in 1.1.1

  • uuidv7() never sorts backwards. Past 4,096 ids in one millisecond it borrows the next millisecond, but the following call with the original time used to jump back. A clock stepping backwards (an NTP correction) did the same. It now stays on the latest timestamp, as ulid() already did.
  • uuidv7() and ulid() reject impossible times. A negative time, NaN, or anything from 2^48 ms up used to produce a wrapped or zero timestamp, and for ULIDs an id that isUlid() rejects. They throw a RangeError now, as the ULID spec requires.
  • Checked and unchanged: version and variant bits, timestamp fields, uniqueness, and an unbiased character distribution in every random generator (chi-square over a million characters).

Install

npm install @lacspace/id      # or pnpm add / yarn add / bun add

Use

import { uuidv4, uuidv7, nanoid, shortId, id } from "@lacspace/id";

uuidv4();          // "f47ac10b-58cc-4372-a567-0e02b2c3d479"
uuidv7();          // "0192e7a1-3c2f-7abc-8def-1234567890ab"  ← sorts by time
nanoid();          // "V1StGXR8_Z5jdHi6B-myT"
shortId();         // "Ab3xK9_p"
id("user");        // "user_9f8c1a3e7b2d4f6a"

Why v7? Because random UUIDs (v4) scatter across a database index, hurting insert performance. v7 is lexicographically sortable by creation time — index-friendly and globally unique — and uuidv7Time(id) reads the timestamp back out.

API

| Export | Description | | --- | --- | | uuidv4() | random UUID | | uuidv7(now?) · uuidv7Time(id) | time-sortable UUID + timestamp extract | | nanoid(size=21) · shortId(size=8) | URL-safe random strings | | id(prefix, size=16) | prefixed id (uses nanoid) | | ulid(now?) · ulidTime(id) | Crockford base32, time-sortable + monotonic | | cuid2(length=24) | collision-resistant, letter-leading id | | snowflakeFactory({ epoch?, machineId?, now? }) · snowflake() · snowflakeTime(id, epoch?) | 64-bit sortable numeric id (decimal string) | | customId({ alphabet, size }) | any alphabet, unbiased (rejection sampling) | | base62Id(size=12) · base58Id(size=12) · ALPHABETS | ready-made short-id helpers + alphabet presets | | prefixedId(prefix, opts?) · parsePrefixedId(value, sep?) | Stripe-style typed ids, round-trippable | | decodeTime(id) | timestamp from a ULID or UUID v7 | | isUuid(s) · uuidVersion(s) · isUlid(s) · isCuid2(s) · isSnowflake(s) | validation |

ALPHABETS presets: numeric, base36, hex, lowercase, base32Crockford, base58, base62.

Licensing

This package is free under the Lacspace Free Licence — permissive freedoms. Use it in personal and commercial projects at no cost; just keep the notice.

Not every Lacspace package is free. We also offer Commercial, Client-specific and Private packages under separate terms — see the Lacspace Licence Centre.


The Lacspace Developer Platform

@lacspace/id is part of 80+ zero-dependency, isomorphic TypeScript packages — one standard library for the modern web. Explore the ecosystem:

  • 📦 This package, documented — https://developer.lacspace.com/packages/id
  • 🗂️ All 80+ packages — https://developer.lacspace.com/packages
  • 🧭 Developer handbook — guides & runnable recipes — https://developer.lacspace.com/handbook
  • 🧪 Live playground — run any package in your browser — https://developer.lacspace.com/playground
  • 🖥️ Finished app templates — https://templates.lacspace.com
  • 🚀 Scaffold a full app — npm create lacspace-app@latest

Free under the Lacspace Free Licence — a permissive, free-to-use licence.