DevToolBox

ULID / NanoID Generator

ULIDとNanoIDをブラウザ内で最大100個まで一括生成します。crypto.getRandomValues使用、外部依存なし。

(1-100)

How to Use the ULID / NanoID Generator

This free online tool generates ULID and NanoID identifiers entirely in your browser using the cryptographically secure crypto.getRandomValues() API — no external library is loaded. Choose ULID or NanoID, set the count (up to 100) and, for NanoID, the length (default 21), then click Generate. Each identifier can be copied individually or all at once.

What Is a ULID?

A ULID (Universally Unique Lexicographically Sortable Identifier) is a 128-bit identifier encoded as 26 characters using Crockford's Base32 alphabet, which excludes the letters I, L, O and the digit U to avoid visual ambiguity. The first 10 characters encode a 48-bit millisecond Unix timestamp, and the remaining 16 characters are cryptographically random. Because the timestamp comes first, ULIDs generated later sort after ULIDs generated earlier when compared as plain strings — a property UUID v4 does not have, since it is entirely random.

What Is a NanoID?

NanoID is a compact, URL-friendly unique ID generator. Its default output is 21 characters drawn from a 64-character alphabet (digits, upper and lowercase letters, underscore and hyphen), which gives a collision probability comparable to UUID v4 while producing a shorter string. This tool implements the same character set and the same random-byte-per-character approach as the reference NanoID algorithm, usingcrypto.getRandomValues() for randomness — with 64 being a power of two, each random byte maps to an alphabet index with a simple bitmask and no statistical bias.

Reading the ULID Timestamp

Each generated ULID in the list above shows its decoded generation time next to it. The highlighted first 10 characters are decoded by treating them as a base-32 number (using the Crockford alphabet) and interpreting the result as milliseconds since the Unix epoch — the same calculation any ULID-aware library performs when sorting or inspecting IDs.

ULID・NanoID生成ツールの使い方

タブでULID・NanoIDを切り替え、生成数(1〜100)を指定して「生成」を押すと一覧が表示されます。 NanoIDは文字数も指定可能です(既定21文字)。ULIDは先頭10文字がタイムスタンプ部のため、 一覧では色付けした上で生成日時をデコードして併記しています。全ての処理はブラウザ内で完結し、 crypto.getRandomValues()による暗号学的に安全な乱数を使用します。

よくある落とし穴と対処 / Common Pitfalls

落とし穴 / Pitfall問題 / Problem対処 / Fix
ULIDのタイムスタンプに機密日時が漏れる
ULID timestamp can leak creation time
先頭48ビットが生成ミリ秒のため、IDから作成日時が誰でも読み取れる
The first 48 bits reveal the exact creation time to anyone
作成日時を秘匿したいリソースにはUUID v4など時刻を含まない方式を使う
Use a time-free scheme like UUID v4 when creation time must stay private
NanoIDの文字集合をUUIDと同じだと思い込む
Assuming NanoID and UUID share the same alphabet
NanoIDは大文字・小文字・アンダースコア・ハイフンを含む64文字。UUIDは16進数(小文字)のみ
NanoID uses a 64-character alphabet; UUID uses only lowercase hex
正規表現でのバリデーションはID方式ごとに個別に定義する
Write separate validation regexes for each ID scheme
Crockford Base32のI/L/O/Uを見落とす
Overlooking that ULID excludes I, L, O, U
ULID文字列にこれらの文字が含まれていれば、それは仕様上無効な値
A ULID containing these letters is invalid by spec
手入力や別システムからの値を検証する際はCrockford Base32アルファベットで照合する
Validate against the Crockford Base32 alphabet, not general Base32
秒間大量生成時の順序性を過信する
Over-relying on ordering for many IDs per millisecond
同一ミリ秒内に生成した複数のULIDはランダム部分の大小関係でしかソートされない
ULIDs generated within the same millisecond only sort by their random suffix
厳密な生成順が必要な場合は単調増加カウンタ付きの実装(monotonic ULID)を検討する
Use a monotonic ULID implementation if strict ordering within a millisecond matters

言語別コード例 / Code Examples

JavaScript / Node.js

// ULID(要 ulid パッケージ)
import { ulid } from "ulid";
ulid(); // "01HZY3K8G0XJ5V9Q7ZC2N4M6R8"

// NanoID(要 nanoid パッケージ)
import { nanoid } from "nanoid";
nanoid(); // 21文字、URL安全な文字集合

Python

# ULID
import ulid
str(ulid.new())

# NanoID
from nanoid import generate
generate(size=21)

SQL (PostgreSQL, 参考)

-- ULIDはCHAR(26)で保存するのが一般的
CREATE TABLE events (id CHAR(26) PRIMARY KEY, ...);
-- 生成順ソートがそのままインデックス順になりB-tree性能が安定する

Why browser-only?

IDs generated here often become database keys or public resource identifiers in your system — values worth generating without a server logging every one it hands out. This tool uses crypto.getRandomValues() for both ULID and NanoID generation entirely in your browser, with no external package loaded and no network request made. Verify it yourself in the DevTools Network tab.

生成したIDはあなたのシステムのキーとして使われるもの。本ツールは外部ライブラリを一切読み込まず、 生成から表示までブラウザ内のcrypto.getRandomValues()のみで完結します。 v4とv7・ULIDの使い分けはUUID v4とv7の違いで詳しく解説しています。

関連ガイド / Related Guide

開発をもっと効率的に

PR