NanoID Generator NanoID 生成器


          

What is NanoID?

NanoID is a secure, URL-friendly, unique string ID generator. It uses a larger alphabet than UUID (64 characters: A-Za-z0-9_-), enabling shorter strings with equivalent cryptographic strength. The default 21-character NanoID has a collision rate comparable to UUID v4. Ideal for database primary keys, public URLs, and short unique identifiers.

NanoID vs UUID

A 21-character NanoID offers roughly the same collision resistance as a UUID v4, but is shorter and URL-safe by default (no hyphens or special characters that need encoding). This tool implements the official NanoID algorithm with crypto.getRandomValues() and rejection sampling to eliminate modulo bias.

什么是 NanoID?

NanoID 是一种安全、URL 友好的唯一字符串 ID 生成器。它使用比 UUID 更大的字符集(64 个字符:A-Za-z0-9_-),在相同加密强度下可生成更短的字符串。默认 21 字符的 NanoID 碰撞率与 UUID v4 相当。非常适合作为数据库主键、公开 URL 和短唯一标识符。

NanoID 与 UUID 的对比

21 字符的 NanoID 提供与 UUID v4 大致相同的抗碰撞能力,但更短,且默认 URL 安全(无连字符或需要编码的特殊字符)。本工具实现官方 NanoID 算法,使用 crypto.getRandomValues() 和拒绝采样消除模偏差。