v4 vs v7
UUID v4 is 122 bits of pure randomness — the classic choice, zero information leakage, no ordering. UUID v7 puts a 48-bit Unix timestamp (ms) first, then random bits: values are sortable by creation time, which makes them better for database primary keys (better insert locality) and logs (time-ordered). Since RFC 9562, v7 is the recommended default for new systems.
Decoding timestamps
In v7 the first 48 bits are the Unix timestamp in milliseconds. In v1/v6 the timestamp is a 60-bit count of 100 ns intervals since 1582-10-15; the decoder reassembles the field order and converts it to a UTC instant — useful for auditing when an ID was minted (e.g. a user record's creation time without a separate column).
Versions at a glance
- v4 — random. Use for tokens, session IDs, anything where ordering is irrelevant.
- v7 — time-sortable. Use for DB keys, event IDs, idempotency keys with time semantics.
- v1 — MAC-address based (privacy leak); v6 — reordered v1. Both use the same 60-bit Gregorian timestamp, and this tool decodes both to UTC.
- UUIDs are 128 bits; collisions with v4 are practically impossible (2^122 space).
Prefer a shorter time-sortable ID? See the ULID Generator — 26 chars vs 36, same idea.