When you actually need a UUID
The canonical use case is distributed systems: when two services need to independently generate IDs for objects that will later be merged, a sequential integer (1, 2, 3…) doesn't work — both services will generate the same numbers. A UUID is 128 bits of randomness that is statistically guaranteed to be unique across all systems and all time.
Common practical uses: primary keys for tables where you want to avoid exposing sequential IDs in URLs, idempotency keys for payment APIs, correlation IDs for log tracing, file upload names, and session identifiers. The recommendation in 2026: use crypto.randomUUID() natively in modern Node.js (v14.17+) and browsers — this is what the tool uses.
UUID versions and which to use
- v4 (random)122 bits of random data. Most commonly used. What this tool generates. Use when you need uniqueness and don't care about sort order.
- v7 (timestamp-ordered)Newer RFC standard that starts with a millisecond timestamp — UUIDs sort chronologically. Better for database primary keys as it avoids random index fragmentation. Node.js 22+ supports it natively.
- v1 (timestamp + MAC address)Includes the device's MAC address — a privacy concern. Largely replaced by v4 and v7 for new applications.
- v5 (SHA-1 namespace hash)Deterministic: same input always produces the same UUID. Useful for generating stable IDs from URLs or other strings.
Collision probability for v4: generating 1 billion UUIDs per second for 85 years gives a 50% chance of a single collision. For practical applications, collisions are not a real concern — the Earth has more atoms than there are possible v4 UUIDs is a common (if slightly overstated) illustration.
How to generate UUID v4 in code — JavaScript, Python, SQL, Go
For runtime UUID generation in your application, every major language has a built-in or standard-library option:
| Language / DB | Code snippet |
|---|---|
| JavaScript (Node 15+) | crypto.randomUUID() |
| JavaScript (browser) | crypto.randomUUID() // also works in browsers |
| Python 3 | import uuid; str(uuid.uuid4()) |
| PostgreSQL | SELECT gen_random_uuid(); -- or uuid_generate_v4() with pgcrypto |
| MySQL 8+ | SELECT UUID(); |
| SQL Server | SELECT NEWID(); |
| Go | import "github.com/google/uuid" uuid.New().String() |
| PHP | Ramsey\Uuid\Uuid::uuid4()->toString() |
| C# / .NET | Guid.NewGuid().ToString() |
| Java | UUID.randomUUID().toString() |
| Ruby | require 'securerandom'; SecureRandom.uuid |
For test fixtures and seed data, use this generator to create a batch of UUIDs and paste them directly into SQL INSERT statements or JSON fixture files — faster than running a script for one-off needs.
