UUID generator · formatUUID v4 — generator and how it works

Version 4 is 122 random bits plus six fixed ones. Nearly every library and database hands it out by default: it reveals nothing about where or when it was made and needs no coordination between machines.

01Generator02Anatomy03Comparison04Questions05Related
01

Generator UUID v4

the format is set — all settings and the checker are in the full generator
Count
Case
Press Generate — identifiers will appear here.
All formats, plus checking and decoding a UUID, are in the full generator →
02

How it is built: UUID v4

Sample550e8400-e29b-41d4-a716-446655440000
550e8400-e29b
random bits, the first 48
4
version: always 4
1d4
12 more random bits
a
RFC variant (8, 9, a or b) plus 2 random bits
716-446655440000
60 more random bits — 122 in all

When to use it

  • An ID that must give nothing away: tokens, request keys, names of uploaded files.
  • A primary key for a small table or a distributed system where insert order does not matter.
  • Anywhere you need “just a unique ID” — it is the default.

How it differs from its neighbours

The main neighbour is v7. Version 4 has no order: new values land all over the range, so in a large table indexed by the key each insert goes to a random spot in the index. Version 7 starts with the time and is appended at the end. For tables growing into millions of rows pick v7; otherwise the difference does not show.

03

Format comparison

FormatLengthRandomnessTime insideSortableStandard
UUID v436122 bitsnonoRFC 9562
UUID v73674 bitsms, 48 bitsyesRFC 9562
UUID v136node and counter100 ns, 60 bitsnoRFC 9562, legacy
Nil UUID36noneno—RFC 9562
NanoID21126 bitsnonoa library, not an RFC
ULID2680 bitsms, 48 bitsyesULID spec, not an RFC
04

Frequently asked questions

Almost everywhere it is one built-in call: crypto.randomUUID() in browsers and Node.js, uuid.uuid4() in Python, UUID.randomUUID() in Java, Guid.NewGuid() in C#, and gen_random_uuid() in PostgreSQL from version 13. All of them produce version 4 from a cryptographic generator. A third-party library is only needed for old environments that lack these functions.

Updated

«» added to favorites