PlayTools

UUID versions: randomness, time, and namespaces

v1・v4・v5形式のRFC 4122 UUIDを一括生成。大文字・ハイフンのカスタマイズにも対応。

Runs in your browser — nothing you enter is uploaded
UUIDバージョン
UUID 5件
ce02cfa1-1685-4e5b-ba99-bd23d8e878ca
b934a08e-43ad-4d69-be99-c22d48c99833
c9e0994f-cf59-4517-8c4b-7888a8fa0fd7
a9f84782-fd72-474c-8a85-4186b4866689
2c8587d6-de12-4c4f-aa15-455e3cdf9e65

UUID v4 の例

550e8400-e29b-41d4-a716-446655440000

形式: 8-4-4-4-12 の16進

このツールの使い方

  1. バージョンを選びます。一般的にはv4(乱数)。
  2. スライダーで個数(最大50)。
  3. システム仕様に応じ大文字化やハイフン削除。
  4. 生成後、個別または一括コピー。

UUID versions: randomness, time, and namespaces

v4 is random (RFC 4122); v1 is time/MAC-derived (privacy concerns on some networks); v5 hashes a namespace + name. Choose v4 for opaque IDs unless you need sortable time proximity.

Database uniqueness still needs constraints—collision probability is tiny but not a substitute for transactional checks.

What each option produces

  • Version 4 (default): 122 random bits from your browser’s cryptographically secure generator, plus the fixed version and variant bits. This is the right choice for almost every new identifier.
  • Version 1: built from the current time as the count of 100-nanosecond intervals since 15 October 1582 (the start of the Gregorian calendar), a random clock sequence, and a random 48-bit node ID with the multicast bit set. Classic v1 used the computer’s network MAC address as the node; the random node keeps your hardware address out of the ID, as RFC 9562 recommends.
  • Nil UUID: all zeros (00000000-0000-0000-0000-000000000000), used as an explicit “no value” marker.
  • Formatting: generate up to 50 at once, switch to uppercase, or remove the hyphens to get a 32-character hex string.

Reading a UUID

A UUID is 128 bits written as 32 hexadecimal digits in five groups (8-4-4-4-12):

f47ac10b-58cc-4372-a567-0e02b2c3d479
              ^    ^
              |    variant: 8, 9, a or b = RFC 9562 layout
              version: 4 = random

The first digit of the third group is always the version, and the first digit of the fourth group shows the variant. That is why a v4 UUID always has a 4 in the 13th position, and why only 122 of the 128 bits are random. For a v1 UUID the first three groups hold the timestamp, so anyone can read off when it was created — something to keep in mind before exposing v1 IDs publicly.

Which version should you use?

  • v4 for general identifiers: API resource IDs, file names, idempotency keys, correlation IDs in logs.
  • v7 for new database primary keys: defined in RFC 9562 (2024), it starts with a Unix-millisecond timestamp, so values sort in creation order and index far better than random v4 keys in B-tree indexes. This tool does not generate v7 yet; most languages have a maintained library for it.
  • v1 when an existing system expects it, for example some older Cassandra schemas (TimeUUID).
  • v5 when the same input must always produce the same ID (it hashes a namespace and a name with SHA-1). Not offered here because it needs those inputs.

Will two UUIDs ever collide?

For v4, the 50% collision point arrives at about 2.7 × 10¹⁸ generated IDs — roughly 86 years of producing a billion UUIDs every second. In practice, a duplicate is far more likely to come from a bug, such as a copied ID or a badly seeded generator in another system, than from chance. Keep a unique constraint on the database column anyway; it costs nothing and catches the bugs.

Unpredictable is not the same as secret. RFC 9562 advises against assuming UUIDs are hard to guess, so do not use one as a password-reset or session token — use a dedicated random token instead.

Storing and comparing UUIDs

  • Use a native type where one exists — uuid in PostgreSQL, uniqueidentifier in SQL Server — or BINARY(16) in MySQL. Storing the 36-character string takes more than twice the space and slows indexes.
  • Compare case-insensitively: f47ac10b… and F47AC10B… are the same UUID. Microsoft tools traditionally show GUIDs in uppercase, often wrapped in braces {…}.
  • Hyphen-free 32-character strings are common in URLs and file names. Most parsers accept both forms, but be consistent within one system.

Generating UUIDs in code

When you need IDs at runtime rather than a handful to paste, every mainstream platform has a built-in v4 generator:

JavaScript   crypto.randomUUID()            // browsers (HTTPS) and Node.js
Python       import uuid; uuid.uuid4()
Java         java.util.UUID.randomUUID()
C# / .NET    Guid.NewGuid()
PostgreSQL   SELECT gen_random_uuid();      -- built in since v13
Go           uuid.New()                     // github.com/google/uuid
Shell        uuidgen                        # macOS prints uppercase

In their current implementations these use the operating system’s secure random source, like this page does. Avoid hand-rolled versions built on Math.random(), which older code snippets online still copy around.

These free tools pair well with this page — open them in a new tab to finish your workflow.

よくある質問

UUIDとは何ですか?

UUID(汎用一意識別子)は、コンピュータシステムで情報を一意に識別するために使用される128ビットの数値です。8-4-4-4-12にグループ化された32の16進数で表されます。

UUIDのバージョンの違いは何ですか?

UUID v1は現在のタイムスタンプとMACアドレスを使用します。UUID v4は乱数を使用し、最も一般的に使われるバージョンです。時間ベースの順序付け(v1)または名前ベースの決定性(v3/v5)が特に必要でない限り、v4が推奨されます。

UUIDは本当に一意ですか?

UUID v4は122のランダムビットを持ち、約2¹²²(約5.3×10³⁶)の可能な値があります。実際のすべての用途で重複が生成される確率は無視できるほど小さいです。

UUIDをデータベースの主キーとして使用できますか?

はい、UUIDは特に自動インクリメント整数が競合する可能性のある分散システムで主キーとして広く使用されています。ランダムUUID(v4)は一部のデータベースでインデックスの断片化を引き起こす可能性があります。

UUIDは大文字と小文字を区別しますか?

いいえ。UUIDの表現は大文字と小文字を区別しません。大文字・小文字の16進数はどちらも有効で等価です。

ブラウザでUUIDを生成するのは安全ですか?

はい。このツールはブラウザ組み込みのcrypto.randomUUID()または暗号学的に安全な乱数生成器を使用するため、出力は本番環境での使用に適しています。