🆔

How to Generate a UUID (Complete 2025 Guide)

Developer · 6 min read · Published March 2025

What UUIDs are, why v4 is the safest version, and how to generate them in JavaScript, Python, PHP, Java, Go and Rust.

What a UUID is

A Universally Unique Identifier is a 128-bit number written as 32 hex digits in 5 groups. Version 4 UUIDs are randomly generated.

Which version to use

For 99% of cases, UUID v4. Use v5 if you need deterministic IDs from a namespace. Never v1 if you do not want to leak MAC or timestamp.

Generating in code

One line in most languages.

  • JavaScript: crypto.randomUUID()
  • Python: import uuid; uuid.uuid4()
  • PHP: random_bytes(16)
  • Java: UUID.randomUUID()
  • Go: github.com/google/uuid
  • Rust: uuid::Uuid::new_v4()

Generate without code

Use our free UUID Generator to produce up to 100 v4 UUIDs at once.

Try our free tools
Browse 85+ free tools → or check our free AI tools directory.

More Developer Guides

Processing…

Please wait a moment