UUID / ULID Generator

Generate UUIDs (v1, v3, v4, v5) or ULIDs, one at a time or 1,000 at once for seeding a table. Use v4 when you only need a unique value, and ULID when you want ids that sort by the time they were made.

Generated IDs

1 UUID / ULID Generator supported formats

UUID v4 (Random)

Use v4 unless you have a reason not to. It carries 122 random bits from the browser's crypto API and needs no coordination between machines.

ULID (Sortable)

Pick ULID for database keys. A 48-bit millisecond timestamp comes first, then 80 random bits, so new rows land at the end of the index instead of scattering across it.

UUID v1 (Time-based)

Built from a timestamp and a node ID. Anyone holding the id can read when it was made, so keep it out of public URLs.

UUID v3 / v5

Deterministic: the same namespace and name always give the same ID. v3 hashes with MD5 and v5 with SHA-1, so prefer v5 for anything new.

2 UUID / ULID Generator example

Generated Output

1
2
// Generated UUID v4
34a02305-6548-430c-a9df-6d7c7c34d284

3 Bulk output stays in your browser

Bulk output

Up to 1,000 ids per click, one per line. That is enough to seed a table or fill a load test without writing a script.

Generated locally

Random bits come from crypto.getRandomValues() in this tab, and the page makes no network call with them. This page does not generate UUID v7; use a library for that.

How to use the UUID / ULID Generator tool

  1. Pick a type from the version dropdown: UUID v4 (Random), UUID v1 (Time-based), UUID v3 (MD5 Namespaced), UUID v5 (SHA-1 Namespaced) or ULID (Sortable).
  2. For v3 and v5, choose a Namespace (URL, DNS, OID or X500) and type the Name, for example example.com. The same namespace and name always produce the same ID.
  3. Set Count to the number of IDs you need, from 1 to 1,000.
  4. Click Generate. The IDs appear one per line under Generated IDs, with a count in the panel header.
  5. Copy takes the whole list; Clear empties the panel.

How to generate a UUID v4, v5 or ULID in JavaScript, PHP and Python

JavaScript / Node.js

const { randomUUID } = require("node:crypto");

// UUID v4: random, built into Node 14.17+ and every modern browser
console.log(randomUUID()); // e.g. 3b241101-e2bb-4255-8caf-4136c566a962

// Several at once
console.log(Array.from({ length: 3 }, () => randomUUID()));

// v1, v3, v5 need the "uuid" package:  npm i uuid
// const { v5: uuidv5, v1: uuidv1 } = require("uuid");
// uuidv5("example.com", uuidv5.DNS); // same input always gives the same ID

// ULID needs the "ulid" package:  npm i ulid
// const { ulid } = require("ulid");
// ulid(); // 01ARZ3NDEKTSV4RRFFQ69G5FAV

In the browser, crypto.randomUUID() is only available on secure contexts (https or localhost).

PHP

<?php
// UUID v4 with no dependencies (PHP 7+)
function uuid4(): string {
    $b = random_bytes(16);
    $b[6] = chr((ord($b[6]) & 0x0f) | 0x40); // version 4
    $b[8] = chr((ord($b[8]) & 0x3f) | 0x80); // RFC 4122 variant
    return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($b), 4));
}
echo uuid4(), PHP_EOL;

// UUID v5 (SHA-1) from a namespace and a name
function uuid5(string $namespace, string $name): string {
    $ns = hex2bin(str_replace('-', '', $namespace));
    $h = sha1($ns . $name, true);
    $h[6] = chr((ord($h[6]) & 0x0f) | 0x50);
    $h[8] = chr((ord($h[8]) & 0x3f) | 0x80);
    return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex(substr($h, 0, 16)), 4));
}
echo uuid5('6ba7b810-9dad-11d1-80b4-00c04fd430c8', 'example.com'), PHP_EOL;
// cfbff0d1-9375-5685-968c-48ce8b15ae17

// For v1, v7 and ULID use ramsey/uuid or symfony/uid via Composer.

Python

import uuid

print(uuid.uuid4())                       # random
print(uuid.uuid1())                       # time + MAC address
print(uuid.uuid5(uuid.NAMESPACE_DNS, "example.com"))
# cfbff0d1-9375-5685-968c-48ce8b15ae17 (always the same)
print(uuid.uuid3(uuid.NAMESPACE_URL, "https://example.com"))

# Generate many
ids = [str(uuid.uuid4()) for _ in range(5)]
print("\n".join(ids))

# ULID:  pip install python-ulid
# from ulid import ULID; print(ULID())

Common errors and how to fix them

TypeError: crypto.randomUUID is not a function
The page is served over plain http on a non-localhost host, or the browser is old. Serve over https, or fall back to crypto.getRandomValues() and set the version and variant bits by hand.
Two servers generated the same v1 UUID
v1 combines a timestamp with a node ID that is often random instead of a real MAC address. Clock rollback or duplicated node IDs on cloned VMs cause collisions. Use v4 or v7 instead.
My v5 UUID does not match the one from another library
The namespace must be the same 16 bytes and the name must be the same bytes. A trailing newline, a different namespace constant or uppercase input produces a different ID.
Inserting UUID v4 primary keys made my MySQL table slow
Random keys scatter inserts across the B-tree. Store them as BINARY(16), and switch to a time-ordered ID such as UUID v7 or ULID so new rows land at the end.

Good to know

A UUID is 128 bits written as 32 hex digits in 8-4-4-4-12 groups. The first digit of the third group is the version, so you can spot a v4 by the 4 in position 15. RFC 9562 (2024) added v6 and v7. v7 puts a Unix millisecond timestamp in the first 48 bits, so it sorts by creation time like a ULID but is still a standard UUID. For ordered database keys, v7 is the default choice now.

ULID solves the same sorting problem with a different encoding: 26 characters of Crockford Base32, 48 bits of time then 80 random bits. It has no hyphens, is case-insensitive and sorts as a plain string by creation time. A ULID is not a UUID, but it is the same 128 bits, so it fits in the same column type.

Specifications and references

This tool follows the specifications below. Read them when you need the exact normative wording, for example to settle an edge case between two implementations.

Frequently Asked Questions

Which UUID version should I use?

Use v4 by default: it is random and needs no coordination between machines. Use v5 (or v3) when the same input must always produce the same ID, and ULID when IDs should sort by creation time, for example as database keys. v1 contains a timestamp but does not sort as a string, because its time fields are stored low bits first.

What is the difference between UUID v3 and v5?

Both derive an ID from a namespace and a name. v3 hashes with MD5 and v5 with SHA-1. Use v5 for anything new; v3 exists for compatibility with older systems.

Are the generated IDs cryptographically random?

Yes. v4 comes from the browser's cryptographically secure generator (crypto.randomUUID() or the uuid library on top of crypto.getRandomValues()), and the random part of a ULID uses crypto.getRandomValues() directly. Both are suitable for identifiers and tokens.

What is a ULID?

A 26-character, case-insensitive identifier: 48 bits of millisecond timestamp plus 80 bits of randomness, written in Crockford Base32. ULIDs sort as plain strings by creation time and are URL-safe.

Can I generate many at once?

Yes. Set Count to anything up to 1,000, click Generate, and Copy takes the whole list, one ID per line.

Related

The first 10 characters of a ULID encode a millisecond timestamp. Decode them to a number and the Unix timestamp converter shows it as a date. When the ids go into a fixture file, the JSON formatter tidies it.

More Generators

Browse all generators

Copied to clipboard!