Skip to content

Repository files navigation

nope-id

🌐 Full documentation: English · Türkçe · Русский

A tiny, secure, URL-friendly unique string ID generator for JavaScript.

A faster, more secure alternative to nanoid with extra features!

  • Faster - 1.4x to 3x faster than nanoid (CSPRNG, full URL-safe alphabet); wins all 5 core benchmarks (see benchmarks)
  • Security Hardened - Reduced timing-leak validators, modulo bias elimination, prototype pollution protection (see security)
  • Well Tested - 408 tests including security & entropy tests (see testing)
  • Cryptographically Secure - Uses webcrypto.getRandomValues() (CSPRNG)
  • Zero Dependencies - No external dependencies
  • URL-safe - Uses A-Za-z0-9_- characters
  • Dual Module - Works with both ESM (import) and CommonJS (require)
  • TypeScript - Full type definitions included
  • Collision-resistant - Strictly-monotonic sortable IDs, origin-tagged distributed IDs
  • Many ID Formats - UUID v4 & v7, ULID (spec-compliant + monotonic factory), Snowflake, MongoDB ObjectId
  • Extra Features - Prefixed IDs, sortable IDs, Sqids (reversible encoding), typed IDs, format validators, and more!

Installation

npm install nope-id

Quick Start

ES Modules (import)

import { nopeid } from 'nope-id'

const id = nopeid() // "V1StGXR8_Z5jdHi6B-myT"

CommonJS (require)

const { nopeid } = require('nope-id')

const id = nopeid() // "V1StGXR8_Z5jdHi6B-myT"

Default Export

// ES Modules
import nopeid from 'nope-id'
const id = nopeid() // "V1StGXR8_Z5jdHi6B-myT"

// CommonJS
const nopeid = require('nope-id')
const id = nopeid() // "V1StGXR8_Z5jdHi6B-myT"

More Examples

Custom alphabets (full API reference):

import { customAlphabet } from 'nope-id'

const hexId = customAlphabet('0123456789abcdef', 16)
hexId()   // "4f90d13a42f17f80"
hexId(8)  // "a3b2c1d4"

Prefixed IDs for database entries (more):

import { prefixedId } from 'nope-id'

prefixedId('user')           // "user_V1StGXR8_Z5jdHi6B-myT"
prefixedId('order', 10)      // "order_IRFa-VaY2b"
prefixedId('prod', 8, '-')   // "prod-Z5jdHi6B"

Sortable, strictly-monotonic IDs (more):

import { orderedId } from 'nope-id'

orderedId()                   // "1okw67hF111114mDXU1ez" (21-char Base58, sortable)
orderedId() < orderedId()     // true (strictly increasing, clock-rewind safe)
orderedId.many(1000)          // 1000 sortable IDs, faster than a loop
orderedId.parse('1okw67hF111114mDXU1ez') // { timestamp: Date, counter, random }

UUID v4 & v7, ULID and more (all formats):

import { uuid, uuidv7, ulid, decodeTime } from 'nope-id'

uuid()              // "e2ef524f-bce6-4c4e-b7dd-2c4b3a6e1d0f" (v4)
uuidv7()            // "0192f3c1-8e2a-7b3c-9d4e-5f60718293a4" (time-ordered)
ulid()              // "01ARZ3NDEKTSV4RRFFQ69G5FAV"
decodeTime(ulid())  // Date

Secure bearer tokens — API keys, session tokens (more):

import { secureToken, apiKey } from 'nope-id'

secureToken()          // 48-char URL-safe token (unpooled, raw bytes zeroized)
apiKey('sk_live', 40)  // "sk_live_<40 chars>"

Documentation

The full documentation lives in docs/README.md (also available in Türkçe and Русский):

Performance

The core head-to-head vs the latest installed nanoid (auto-refreshed by CI on every PR):

Last refreshed: 2026-09-22, Node v26.x, ubuntu-latest (GitHub Actions).

Test nanoid 6.0.1 nope-id Winner
Basic (21 chars) ~26.7M ops/sec ~55.7M ops/sec nope-id ~2.1x
Small (10 chars) ~35.3M ops/sec ~51.5M ops/sec nope-id ~1.5x
Large (64 chars) ~10.8M ops/sec ~32.9M ops/sec nope-id ~3x
Custom Alphabet ~32.4M ops/sec ~67.2M ops/sec nope-id ~2.1x
Batch (100 IDs) ~258K ops/sec ~759K ops/sec nope-id ~2.9x

Changelog

See the GitHub Releases page for the detailed changelog.

License

MIT

About

A tiny, secure, blazing-fast Swiss Army knife for JavaScript IDs URL-safe strings, UUID v4/v7, ULID, Snowflake, ObjectId, Sqids, sortable & typed IDs. Zero dependencies, CSPRNG-powered, TypeScript-ready.

Topics

Resources

Stars

24 stars

Watchers

1 watching

Forks

Releases

Sponsor this project

Packages

Contributors

Languages