UUID Generator v4 — Generate Random UUIDs Online Instantly
Need a unique identifier? Generate one (or a hundred) in a single click. No libraries, no code, no sign-up.
🆔 Generate UUIDs Now
One click, instant UUIDs. Bulk generation and one-click copy included.
Open UUID Generator →What Is a UUID?
A UUID (Universally Unique Identifier) is a 128-bit identifier that's designed to be unique across all space and time without requiring a central authority. The standard format looks like this:
550e8400-e29b-41d4-a716-446655440000
That's 32 hexadecimal characters arranged in 5 groups separated by hyphens: 8-4-4-4-12. UUIDs are defined by RFC 4122 and are one of the most widely used identifier formats in software development.
UUID Version 4: The Random One
There are several UUID versions, but UUID v4 is by far the most popular for general-purpose use. Version 4 UUIDs are generated using random (or pseudo-random) numbers. Of the 128 bits, 122 are random, 4 bits indicate the version (0100 for v4), and 2 bits indicate the variant.
This means there are approximately 5.3 × 10³⁶ possible UUID v4 values. To put that in perspective: you could generate 1 billion UUIDs per second for 100 years and the probability of a single collision would still be astronomically small — roughly 50% chance after generating 2.71 × 10¹⁸ UUIDs.
Anatomy of a UUID v4
550e8400-e29b-41d4-a716-446655440000
^ ^
| |
| Variant (8, 9, a, or b)
Version (always 4)
The third group always starts with 4 (version), and the fourth group always starts with 8, 9, a, or b (variant). This is how you can identify a UUID v4 at a glance.
All UUID Versions Compared
- v1 — Time-based: Uses the current timestamp and MAC address. Sortable by creation time but leaks hardware identity.
- v2 — DCE Security: Similar to v1 with POSIX UID/GID. Rarely used in practice.
- v3 — Name-based (MD5): Deterministically generated from a namespace and name using MD5 hashing.
- v4 — Random: Generated from random numbers. The most widely used version.
- v5 — Name-based (SHA-1): Like v3 but uses SHA-1. Preferred over v3 for new systems.
- v7 — Time-ordered (new): Combines Unix timestamp with randomness. Sortable and database-friendly. The modern alternative to v1.
When to Use UUID v4
UUID v4 is the right choice when:
- You need unique identifiers without coordination between systems
- Database primary keys in distributed systems where auto-increment doesn't work
- API resource identifiers that shouldn't be guessable or sequential
- Session tokens and temporary identifiers
- Correlation IDs for distributed tracing and logging
- File names for uploads and temporary files
When NOT to Use UUID v4
- When you need sortability: UUID v4 is random — it doesn't sort chronologically. Use UUID v7 or ULID instead.
- As database primary keys with B-tree indexes: Random UUIDs cause index fragmentation. UUID v7 or sequential IDs are better for database performance.
- When you need deterministic IDs: Use UUID v5 to generate the same ID from the same input consistently.
- When space is critical: At 36 characters (with hyphens), UUIDs are verbose. Consider shorter alternatives like nanoid or KSUID.
Generating UUIDs in Code
// JavaScript (browser)
crypto.randomUUID()
// "3b241101-e2bb-4d7a-8613-e4cf2b04ac9b"
// Node.js
const { randomUUID } = require('crypto');
randomUUID();
# Python
import uuid
str(uuid.uuid4())
// Java
UUID.randomUUID().toString();
// Go
import "github.com/google/uuid"
uuid.New().String()
# CLI (Linux/macOS)
uuidgen
# Or with Python one-liner
python3 -c "import uuid; print(uuid.uuid4())"
For Python developers specifically, check out our detailed guide on how to generate UUIDs in Python with examples and best practices. Or just use our UUID generator for quick generation without opening a terminal or writing code.
UUID Best Practices
- Always use cryptographically secure randomness:
crypto.randomUUID(), notMath.random()-based generators. - Store as binary when possible: A UUID is 16 bytes binary but 36 bytes as a string. In databases, binary storage saves space and improves query performance.
- Lowercase is canonical: UUIDs are case-insensitive, but the canonical form uses lowercase hex. Be consistent.
- Don't strip hyphens for storage: Most databases and libraries expect the hyphenated format. Removing hyphens saves only 4 bytes and causes compatibility issues.
- Consider UUID v7 for new projects: If you're starting fresh and need time-sortable identifiers, UUID v7 (RFC 9562) gives you the best of both worlds.
Recommended Tools & Resources
Level up your workflow with these developer tools:
MongoDB Atlas Free Tier → Supabase (Postgres) → Designing Data-Intensive Applications →Dev Tools Digest
Get weekly developer tools, tips, and tutorials. Join our developer newsletter.
UUID FAQ
Can UUID v4 collide?
Theoretically yes, practically no. The odds of collision are so astronomically small that you'd need to generate billions of UUIDs per second for decades before having a meaningful chance. In real applications, it's effectively impossible.
Are UUIDs secure?
UUID v4 generated with a cryptographic random source is unguessable — you can't predict the next UUID from seeing previous ones. However, UUIDs are not encrypted and shouldn't be used as passwords or secret tokens.
What's the difference between UUID and GUID?
Functionally, nothing. GUID (Globally Unique Identifier) is Microsoft's term for the same thing. See our GUID vs UUID article for the full story.
Frequently Asked Questions
What is UUID v4?
UUID v4 is a randomly generated 128-bit identifier in the format xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx. The '4' indicates version 4, and the 'y' is 8, 9, a, or b. It's the most common UUID type used in software.
How do I generate a UUID v4?
Use our free tool at devtoolkit.cloud/tools/uuid-generator for instant generation. In code: Python's uuid.uuid4(), JavaScript's crypto.randomUUID(), or Java's UUID.randomUUID().
Can UUID v4 have collisions?
Theoretically yes, but practically no. With 2^122 possible values, you'd need to generate 2.71 quintillion UUIDs to have a 50% chance of one collision. For any real-world application, collisions are impossible.