UUID / ULID / Snowflake Generator
Generate UUID v4, UUID v7, ULID, and Snowflake IDs in bulk. Decode existing IDs to inspect version and timestamp. Includes Laravel Str:: helper equivalents.
Generate
Decode / Inspect
When to use each format
| Format | Sortable | Timestamp | Use case |
|---|---|---|---|
| UUID v4 | No | No | General purpose, most common |
| UUID v7 | Yes | ms | Database primary keys (indexed) |
| ULID | Yes | ms | Lexicographically sortable IDs |
What is a UUID / ULID Generator?
A UUID (Universally Unique Identifier) generator creates globally unique 128-bit identifiers without requiring a central authority or database sequence. UUIDs are the standard for distributed systems, public-facing IDs in REST APIs, and database primary keys where you want to avoid sequential integer exposure. This free online UUID generator supports UUID v4 (random), UUID v7 (time-ordered), and ULID (Universally Unique Lexicographically Sortable Identifier) - with a built-in decoder that extracts the timestamp and version from any existing ID.
UUID v4 vs UUID v7 vs ULID
UUID v4 is 122 bits of cryptographically random data - fully unpredictable, widely supported, but not sortable. Inserting random UUIDs into a B-tree index causes page splits and fragmentation, slowing writes on large tables. UUID v7 solves this by embedding a millisecond Unix timestamp in the most significant bits - making it monotonically increasing and index-friendly while retaining 74 bits of randomness. ULID encodes the same 48-bit timestamp plus 80 random bits in a 26-character Crockford Base32 string, making it lexicographically sortable and safe to use in URLs. Laravel 11+ ships with Str::uuid() (v4) and Str::ulid() natively; UUID v7 is available via Str::uuid7() as of Laravel 11.x.
Frequently Asked Questions
Should I use UUIDs or auto-increment IDs for database primary keys?
It depends on your use case. Auto-increment integers are compact (4–8 bytes vs 16 bytes), faster to index, and simpler to debug. UUIDs are better when: you generate IDs client-side before inserting, you merge records from multiple databases, you want to avoid exposing sequential IDs in URLs (which reveals record count and enables enumeration attacks), or you're building a distributed system. UUID v7 or ULID are the best compromise - sortable like integers, unique like UUIDs.
How do I use UUID primary keys in Laravel?
Add the HasUuids trait to your model: use Illuminate\Database\Eloquent\Concerns\HasUuids;. In the migration, use $table->uuid('id')->primary(). Laravel will automatically generate a UUID v4 on model creation. For UUID v7, override newUniqueId() to return (string) Str::uuid7(). For ULID primary keys, use the HasUlids trait instead.
What is the difference between UUID and GUID?
GUID (Globally Unique Identifier) is Microsoft's term for UUID. They are the same 128-bit format and interchangeable. Microsoft's SQL Server and .NET use GUID; Linux, PHP, and most web frameworks use UUID. Both follow the RFC 4122 standard (for versions 1–5) or the newer RFC 9562 (for versions 6–8). The string representation is identical: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.
Can two UUIDs ever be the same?
In theory yes, but in practice no. UUID v4 has 2^122 possible values - roughly 5.3 × 10^36. Generating a duplicate would require producing approximately 2.7 × 10^18 UUIDs (about 1 billion per second for 85 years) before the probability of a single collision reaches 50%. For any real-world application, UUID v4 collisions are effectively impossible. UUID v7 and ULID add a monotonic timestamp, further reducing collision probability within the same millisecond.