26 文字の Crockford-base32。ミリ秒タイムスタンプで辞書順ソート可能。ローカルで生成され、外部へ送信されません。
機能の説明
ULIDULIDA 128-bit identifier like a UUID, but timestamp-prefixed and Crockford-base32 encoded — so it sorts by creation time and is shorter to read.
を生成します。ULID は 26 文字の識別子で、ミリ秒単位のタイムスタンプと 80 ビットのランダム性を組み合わせたものです。ツールは読み込まれた瞬間に自動で埋められ、オプションを変更するたびに再生成されるため、常に画面に結果が表示されています。Count は 1 から 1,000 まで設定できます。単一の値は大きな文字で表示され、バッチはリストとして表示されます。Copy はバッチ全体を取得します。すべてcrypto.getRandomValues を使ってローカルで実行されます。
使い方
- Count を設定します(1 〜 1,000)。変更すると結果が再生成されます。
- 結果を読みます。1 つなら大きな文字で、2 つ以上ならリストで表示されます。
- Copy を押すとバッチ全体を取得できます。
- 任意の
ULIDULIDA 128-bit identifier like a UUID, but timestamp-prefixed and Crockford-base32 encoded — so it sorts by creation time and is shorter to read.
を Decode aULIDULIDA 128-bit identifier like a UUID, but timestamp-prefixed and Crockford-base32 encoded — so it sorts by creation time and is shorter to read.
に貼り付けると中身を検査できます。ツールは時間部分とランダム性を分離し、タイムスタンプをミリ秒と ISO-8601 UTC で表示します。不正な入力(長さの誤り、Crockford に含まれない文字、48 ビットの上限を超えた時間部分)には、その正確な理由が表示されます。
例
ULIDULIDA 128-bit identifier like a UUID, but timestamp-prefixed and Crockford-base32 encoded — so it sorts by creation time and is shorter to read.
は 26 文字です。その分割こそが要点です:01ARZ3NDEKTSV4RRFFQ69G5FAV
└──┬──┘└───────┬────────┘
timestamp randomness
(10 chars) (16 chars)
01ARZ3NDEKTSV4RRFFQ69G5FAV— 仕様の正規例01ARZ3NDEK...は01ARZ3NDF...より前にソートされる。文字列の先頭に 10 文字のタイムスタンプが置かれているためです01ARZ3NDEKTSV4RRFFQ69G5FAVをデコーダーに貼り付けると、タイムスタンプ2016-07-30T23:54:10.259Zが読み取れます — 仕様の正規例は 2016-07-30 に作られたものです
ULIDULIDA 128-bit identifier like a UUID, but timestamp-prefixed and Crockford-base32 encoded — so it sorts by creation time and is shorter to read.
の仕組みULIDULIDA 128-bit identifier like a UUID, but timestamp-prefixed and Crockford-base32 encoded — so it sorts by creation time and is shorter to read.
は 128 ビットで、2 つに分割されています:| 部分 | ビット | 文字数 | 格納するもの |
|---|---|---|---|
| Timestamp | 48 | 先頭 10 文字 | Unix エポックからの経過ミリ秒 |
| Randomness | 80 | 末尾 16 文字 | ランダムビット |
両方の部分は Crockford base32 でエンコードされます。32 個の記号を使い、1 文字あたり 5 ビットです。アルファベットは 0-9 と、A-Z から I、L、O、U を除いたものです。そのため
ULIDULIDA 128-bit identifier like a UUID, but timestamp-prefixed and Crockford-base32 encoded — so it sorts by creation time and is shorter to read.
は大文字小文字を区別せず、読み間違えやすい文字(I を 1、O を 0)が除去されています。26 文字 × 5 ビット = 130 なので、上位 2 ビットは未使用のままです。
タイムスタンプこそが導入する価値です。 タイムスタンプは値の最上位側に配置されるため、文字列の順序=作成順序になります。
ULIDULIDA 128-bit identifier like a UUID, but timestamp-prefixed and Crockford-base32 encoded — so it sorts by creation time and is shorter to read.
の列をプレーンテキストとしてソートすれば、挿入順序がそのまま得られます。UUIDv4 と比較してください:| 性質 | ULIDULIDA 128-bit identifier like a UUID, but timestamp-prefixed and Crockford-base32 encoded — so it sorts by creation time and is shorter to read. |
UUIDv4 |
|---|---|---|
| 文字数 | 26 | 36(ハイフン 4 つを含む) |
| 作成時刻でソート可能 | はい(辞書順) | いいえ — 完全にランダムな順序 |
| ランダムビット | 80 | 122 |
識別子が一意でさえあればよいなら UUIDv4 で十分です。ソートも必要な場合 — データベースキー、イベントログ、ページングして読む類のもの — には、タイムスタンプの接頭辞によってインデックススキャンが範囲読み取りに変わります。48 ビットのミリ秒クロックは西暦 10889 年まで届くため、実用上オーバーフローはありません。
同じミリ秒でも ULIDULIDA 128-bit identifier like a UUID, but timestamp-prefixed and Crockford-base32 encoded — so it sorts by creation time and is shorter to read.
補足事項
- ソートはできても順序の保証はない。
ULIDULIDA 128-bit identifier like a UUID, but timestamp-prefixed and Crockford-base32 encoded — so it sorts by creation time and is shorter to read.
はミリ秒単位でソートされます。1 ミリ秒内の 2 つの ID には順序の保証がありません。 - 大文字小文字を区別しない。
01arz3ndektsv4rrffq69g5favは大文字の形式と同じ値として解釈されます。 - プライベート: ブラウザー内でローカルに生成されます。どこにも何も送信されません。
- 関連ツール:
UUIDUUIDA 128-bit identifier generated to be practically unique without coordination, most commonly in version-4 (fully random) form.
Generator、Token Generator。