Skip to content
id

NanoID & Custom NanoID

Compact, URL-friendly, cryptographically secure unique string identifiers with custom alphabet and size configuration.

1 min read137 words

NanoID is a tiny, secure, URL-friendly unique string generator. It uses a 64-character URL-safe alphabet (A-Za-z0-9_-) by default and produces 21-character strings with equivalent collision resistance to UUIDv4 while saving 40% of character length.

Standard nanoId()

Generates a standard 21-character string using the native Web Cryptography API with uniform distribution:

js

import { nanoId } from '@readytools/id';

const id = nanoId();
// Returns: "V1StGXR8_Z5jdHi6B-myT"
⚡ Live Playground

nanoId()

Generating...

📏 Calculating...✨ Web Crypto Native

customNanoId(alphabet, size)

The customNanoId function produces unique identifiers using a custom character dictionary and custom string length with zero modulo bias. Ideal for OTP codes, booking references, and custom tokens:

js

import { customNanoId } from '@readytools/id';

// 6-digit numeric SMS verification code
const otp = customNanoId('0123456789', 6);
// e.g. "491823"

// 8-character uppercase booking reference
const bookingCode = customNanoId('ABCDEFGHJKLMNPQRSTUVWXYZ23456789', 8);
// e.g. "K9M2P4X7"

// 16-character lowercase hex token
const hexToken = customNanoId('0123456789abcdef', 16);
// e.g. "a3f89012c45e67b9"
⚡ Live Playground

customNanoId()

Generating...

📏 Calculating...✨ Web Crypto Native

Collision Probability Analysis

A standard 21-character NanoID with an alphabet of 64 characters provides $\approx 126$ bits of entropy. Generating 1 billion IDs per second for over 4,000 years would only yield a 1% probability of encountering a single collision.

Previous

UUID — v1, v4, v5, v7

Next

ULID — Universally Unique Lexicographically Sortable Identifier


Top-Werkzeuge

WorkspaceLinksySEO-AnalyzerChromoQR-Code-Generator

ReadyTools

KarriereKontaktWerkzeuge
Preise7 Tage gratis
SupportSicherheitAnleitungenDocsBlogUpdatesLaraVault

Sprache wählen

Thema wählen

ReadyTools

© 2026 ReadyTools. Alle Rechte vorbehalten.