Promptyard
Encoding

UUID Generator (v4 / v7)

Generate UUID v4 (random) or v7 (time-ordered). Bulk regenerate up to 100 at once.

    v7 IDs are time-ordered — sortable by creation time. Use them as primary keys instead of v4 to avoid index fragmentation in databases. v4 is purely random.

    v4 vs v7 in one paragraph

    v4 is 122 bits of randomness — perfectly distributed across the keyspace, which is great for entropy and bad for B-tree indexes (each insert is a random write). v7 prepends a 48-bit millisecond timestamp, so consecutive inserts hit nearby pages and your index stays compact. For new database schemas in 2024+, default to v7 unless you have a specific reason not to.

    FAQ

    v4 vs v7 — which one?
    v7 if you control the database. Time-ordered UUIDs are friendlier to B-tree indexes, reducing fragmentation and write amplification. v4 is fine for ephemeral tokens or when ordering doesn't matter.
    Are these cryptographically random?
    Yes. They use crypto.randomUUID (v4) or crypto.getRandomValues (v7) — Web Crypto API, CSPRNG. Don't use these as session secrets, but they're collision-safe.
    Collision risk?
    For v4: 2¹²² random bits. Generating a billion per second for a century gives ~50% chance of one collision — effectively never. v7 is similar but anchored to time.
    Why isn't v7 in my standard library?
    It's newer (RFC 9562, 2024). Node.js 22+ has it; older runtimes need a polyfill. Major databases (Postgres, MySQL) accept it as a regular UUID.

    Related tools