Skip to content
Toolblip
← Blog
Developer Tools4 min read·

Generate UUIDs Online: Why V4 Is the Right Choice for Most Applications

A UUID v4 generator creates unique identifiers with virtually zero collision risk. Learn how UUIDs work, why version 4 is the most practical choice for web and app development, and how to use Toolblip's UUID generator.

Every database row, every document, every session — something has to give each one a unique ID. If you're building anything with a database, you've faced this problem. The solution most developers land on is UUIDs.

But not all UUIDs are the same. There are five versions, and version 4 is almost always the right one.

What Is a UUID?

UUID stands for Universally Unique Identifier. It's a 128-bit value formatted as a 36-character string:

550e8400-e29b-41d4-a716-446655440000

The format breaks down as:

  • 8 hex digits (32 bits) — time_low
  • 4 hex digits (16 bits) — time_mid
  • 4 hex digits (16 bits) — time_hi_and_version
  • 4 hex digits (16 bits) — clock_seq
  • 12 hex digits (48 bits) — node

That's 2^128 possible values. To put that in perspective: if you generated a billion UUIDs per second, it would take longer than the age of the universe to have a 50% chance of generating a duplicate.

The Five UUID Versions

Version 1 — Time-based. Combines a timestamp and the machine's MAC address. Theoretically sortable by time, but exposes your MAC address (a privacy concern).

Version 4 — Random. Pure random generation. No timestamp, no MAC address, no clues about when or where it was created.

Version 5 — SHA-1 hash of a namespace and name. Deterministic — the same input always produces the same UUID. Good for URL-safe namespacing.

Version 7 — Timestamp-based, like v1 but uses Unix timestamp instead of Gregorian. More sortable, less privacy-leaking than v1.

Version 3 — MD5 hash of namespace + name. Older, less preferred than v5.

Why UUID v4 Is the Default Choice

Here's why v4 dominates:

No external dependencies. A v4 UUID is just random bits. No timestamp server, no namespace registry, no coordination. Generate anywhere.

No information leakage. V1 exposes your MAC address. V4 reveals nothing. Every octet is random.

Collision risk is negligible. The birthday paradox says you need about 2^64 values before a 50% chance of collision. In practice, you'll never hit that.

Database-friendly. UUIDs can be primary keys, foreign keys, session tokens, event IDs — anything that needs uniqueness without coordination.

When to Choose a Different Version

Use v7 instead of v1 if you need time-sortable IDs. V7 combines a Unix timestamp (48 bits) with random bits for a monotonically increasing ID that's also unique. Think: Instagram's Snowflake alternative, but self-contained.

Use v5 if you need deterministic IDs from names. For example, if you want to generate the same UUID for "[email protected]" every time from any machine, namespace + name → v5 gives you that.

Use v1 in rare cases where you genuinely need the maximum Sortability and don't mind the MAC address exposure (internal systems behind a firewall, for example).

UUID v4 in Different Languages

Generating a v4 UUID is trivial in every language:

// JavaScript / Node.js
import { v4 as uuidv4 } from 'uuid';
uuidv4(); // '9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d'
# Python
import uuid
str(uuid.uuid4())  # '7c9e6679-7425-40de-944b-e07fc1f90ae7'
// Go
import "github.com/google/uuid"
uuid.NewV4().String() // "550e8400-e29b-41d4-a716-446655440000"

Common UUID Myths Debunked

Myth: UUIDs are too long for URLs.
Fact: A UUID is 36 characters. In URLs, base64-encode the raw bytes and you get 22 characters. Use whichever fits your use case.

Myth: Auto-increment integers are faster.
Fact: Yes, sequential IDs have better B-tree locality. But UUID v7 (time-sortable) solves this. For most apps, the difference is negligible.

Myth: UUIDs can't be used as primary keys.
Fact: They absolutely can. PostgreSQL, MySQL, MongoDB — all handle UUID primary keys fine. The tradeoff is slightly larger indexes, but the benefits almost always outweigh it.

Use Toolblip's UUID Generator

Instead of writing a script or installing a library just to get one UUID, use Toolblip's UUID Generator. One click gives you:

  • UUID v4 (random) — default, most common
  • UUID v1 (time + MAC)
  • UUID v4 in uppercase or lowercase
  • Bulk generation — up to 100 at once

No sign-up. No library installation. Just generate and copy.

#uuid#identifier#database#backend#api

Harun R Rayhan

Writing about developer tools, web performance, and the tools that make building faster.

More in Developer Tools