โœฆ Developer Tool ยท Interactive
โ† Back to dev

UUID Generator

Create random version 4 UUIDs ready for code, SQL and API testing. See how the format works and when UUID v7 makes a better database primary key.

{ } Developer Toolโšก Instant result
</>
{ } 01 ยท DEVELOP

Need a unique ID without asking a database?

A UUID (Universally Unique Identifier) is a 128-bit value written as 36 characters, like 3f2b8c1e-9a4d-4e7b-b6a1-0c5d2e8f7a93. Any system can create one independently, and the chance of two matching is close to zero. That makes UUIDs handy for distributed apps, offline-first mobile apps and test data.

This UUID generator creates random version 4 identifiers you can copy straight into code, SQL scripts or API requests.

Common uses include primary keys, names for uploaded files, idempotency keys for payment APIs and correlation IDs. A correlation ID lets you trace one request as it passes through several microservices.

Reading a UUID: the 8-4-4-4-12 layout

Every UUID contains 32 hexadecimal digits split by four hyphens into groups of 8, 4, 4, 4 and 12. Two positions carry meaning.

  • The first digit of the third group is the version. In a v4 UUID it is always 4.
  • The first digit of the fourth group is the variant. For standard UUIDs it is 8, 9, a or b.

So in 3f2b8c1e-9a4d-4e7b-b6a1-0c5d2e8f7a93, the 4 starting "4e7b" marks version 4. The b starting "b6a1" marks the standard variant. The remaining 122 bits are random.

One special value is the nil UUID, which is all zeros: 00000000-0000-0000-0000-000000000000. Some systems use it as a placeholder meaning "no ID yet". Never store it as a real key.

UUID v1 vs v4 vs v7: which version should you use?

VersionBuilt fromSortable by time?Good for
v1Timestamp plus node (often MAC address)PartlyLegacy systems; can leak host details
v4122 random bitsNoGeneral IDs, tokens, test data
v5SHA-1 hash of a namespace and nameNoRepeatable IDs from the same input
v7Unix milliseconds plus random bitsYesDatabase primary keys

Random v4 keys scatter inserts across a B-tree index, which can slow large tables. UUID v7, standardised in RFC 9562 in 2024, starts with a timestamp. New rows land near each other, and indexes stay healthier.

How likely is a duplicate UUID?

A v4 UUID has 2^122 possible values, about 5.3 x 10^36. You would need to generate around 2.7 quintillion UUIDs to reach a 50% chance of one collision. In practice, a duplicate points to a bug, such as a poorly seeded random generator, not bad luck.

A good UUID generator should use a cryptographically secure random source, such as crypto.randomUUID() in modern browsers. Still, UUIDs are identifiers, not secrets. Do not use one as a password reset token unless your security review approves it. For quick IDs during development, the ToolsMate UUID generator saves writing a script.

Generating UUIDs in code

  • JavaScript: crypto.randomUUID() returns a v4 string.
  • Python: uuid.uuid4() from the standard library.
  • PostgreSQL: gen_random_uuid(), built in from version 13.
  • MySQL: UUID(), which returns a version 1 value.
</> 02 ยท UNDERSTAND

How this developer tool works

01

Enter the required information

Use the fields in the tool above and keep units and formats consistent.

02

Run the tool

Review the result shown in the output area.

03

Check the assumptions

Confirm that the result matches your situation before using it for a decision.

</> 03 ยท FORMULA / LOGIC

Which formula or logic is used?

</>A browser cryptographic UUID is generated with crypto.randomUUID().

This describes the core logic used by the tool. Check any assumptions that may affect your result.

โœฆ 04 ยท IMPORTANT

Things to know before using UUID Generator

01

Use accurate inputs and keep units consistent.

02

Review the assumptions before using the result for a decision.

03

Compare important results with an independent or official source.

? 05 ยท FAQ

Frequently Asked Questions

What is the difference between a UUID and a GUID?+

They are the same 128-bit identifier format under two names. GUID is the term Microsoft uses in Windows and .NET, while UUID is the name in the RFC standard. Both follow the same 8-4-4-4-12 hexadecimal layout.

Can two UUIDs ever be the same?+

In theory yes, but with version 4 the odds are tiny. You would need billions of IDs every second for decades to expect one collision. Real duplicates usually come from faulty random number generators or copied seed values.

Is UUID v4 good for a database primary key?+

It works, but random values spread inserts across the index and can hurt write speed on large tables. Many teams now prefer UUID v7 or ULIDs, which begin with a timestamp and keep new rows grouped together.

How do I generate a UUID in JavaScript?+

Modern browsers and Node.js 19 and later provide crypto.randomUUID(), which returns a version 4 UUID string. Older environments often use the uuid package from npm, which supports versions 1, 4, 5 and 7.

Are UUIDs case sensitive?+

The standard says UUIDs should be output in lowercase but accepted in either case when read. So 3F2B and 3f2b represent the same value. Store them consistently, since some databases compare text strings with case sensitivity.

How long is a UUID in characters?+

The usual text form is 36 characters: 32 hexadecimal digits plus four hyphens. Without hyphens it is 32 characters. Stored as binary in a database column, it takes only 16 bytes, which saves space and speeds comparisons.

Should I use a UUID as a secret API key?+

Not on its own. A v4 UUID carries 122 random bits, but some libraries do not use secure randomness. UUIDs also often appear in logs and URLs. Generate API keys with a dedicated secure token function instead.

โ—Ž 08 ยท CATEGORY HUBS

Explore TheToolsMate