Developer ToolsBy Sam Holloway··4 min read

UUID vs GUID: What Is the Difference?

UUID and GUID are the same thing. GUID is Microsoft's name for UUID v4. This guide explains the difference in plain English, covers UUID versions v1 through v7, and shows when to use each one.

UUID and GUID are the same thing. UUID stands for Universally Unique Identifier. GUID stands for Globally Unique Identifier. Microsoft coined the term GUID in the 1990s for its own software, but the format is identical to the open UUID standard. If you see GUID in a Microsoft product and UUID everywhere else, that is why: same format, different name.

What is a UUID?

A UUID is a 128-bit number, usually written as 32 hexadecimal characters grouped by hyphens: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx. For example: 550e8400-e29b-41d4-a716-446655440000. The format is defined by the Internet Engineering Task Force (IETF) in RFC 4122. The goal is to generate identifiers that are unique across every computer, every database, and every application in the world, without any central authority assigning them.

UUID versions: v1 through v7

There are seven officially defined UUID versions. Each uses a different method to generate the identifier. The version number is the first digit of the third group (the digit after the second hyphen).

VersionHow it worksBest used for
v1Combines the current timestamp with the MAC address of the machine generating it. Produces sortable, time-ordered IDs.Distributed systems that need time-ordered records and can tolerate leaking the generating machine's network address.
v2Similar to v1 but embeds a POSIX user or group ID. Rarely used in practice.Legacy enterprise systems. Avoid in new projects.
v3Deterministic: generates a UUID from a namespace and a name using MD5 hashing. Same input always produces the same UUID.Generating stable IDs for known resources (e.g. a UUID for a URL that must never change).
v4Completely random. 122 of the 128 bits are randomly generated. This is the most widely used version and is what Microsoft calls a GUID.General-purpose unique identifiers: database primary keys, API tokens, session IDs, file names.
v5Deterministic: like v3 but uses SHA-1 instead of MD5. More collision-resistant.Same use cases as v3, but preferred over v3 in new code because SHA-1 is stronger than MD5.
v6A reordered version of v1, designed to sort correctly as a database index. Keeps the timestamp but reorganises the bits so the UUID sorts chronologically.Database primary keys where insertion order matters and you want time-sortable IDs without the privacy issues of v1.
v7Unix timestamp plus random bits. Monotonically increasing within the same millisecond. The newest version, designed for modern databases.The best choice for new database primary keys: time-sortable, random enough to avoid collisions, and compatible with most modern databases.

Which version should you use?

For most projects, the answer is v4 or v7.

  • Use v4 when you need a random, one-off identifier and do not care about sort order. It is the default in most UUID libraries and the safest choice for API tokens, session IDs, and any ID that will not be used as a database primary key.
  • Use v7 when the UUID is a database primary key and you want records to insert in time order. Databases index sequential values far more efficiently than random ones, so v7 significantly reduces index fragmentation at scale.
  • Use v5 (or v3) when you need the same input to always produce the same UUID. For example, generating a stable UUID for a given URL or email address.
  • Avoid v1 and v2 in new projects. v1 leaks the MAC address of the generating machine, which is a minor privacy issue. v2 is practically obsolete.

How to generate a UUID

Every major programming language has a built-in or standard-library method for generating UUID v4:

javascript
// JavaScript / Node.js (v14.17+)
crypto.randomUUID()
// "3b12f1df-5232-4804-897e-917bf397618a"

// Python
import uuid
str(uuid.uuid4())
# '3b12f1df-5232-4804-897e-917bf397618a'

// PostgreSQL (generates v4 in the database)
SELECT gen_random_uuid();

If you want to generate a UUID instantly in your browser without writing any code, use AlteredIdea's UUID Generator. It runs entirely in your browser: nothing is sent to a server.

Generate a UUID right now: AlteredIdea's UUID Generator is free, browser-based, and works offline. Use the button below.

S

Sam Holloway

Sam is a technical writer and developer who has spent over a decade building web tools and writing about software, security, and the web platform. He focuses on making complex topics genuinely useful for working developers and non-technical users alike.

Try it yourself

UUID Generator

Free, browser-based: your files never leave your device.

Open tool