Home / UUID Generator / Java
UUID Generator for Java
Generate a UUID right here, or copy the exact Java code to generate one in your own project using java.util.UUID, part of core Java since Java 5, no dependency needed.
UUID Generator for Java
Generate a UUID in Java
java.util.UUID has been part of core Java since Java 5, no external dependency needed.
import java.util.UUID;
public class Example {
public static void main(String[] args) {
UUID id = UUID.randomUUID();
System.out.println(id);
// e.g. 550e8400-e29b-41d4-a716-446655440000
}
}
To parse a UUID string back into a UUID object, use UUID.fromString("...").
How this tool works
UUID.randomUUID() in Java uses a cryptographically strong pseudo-random number generator internally to produce a version-4 UUID per RFC 4122, the same standard this page’s own generator follows, which uses the Web Crypto API’s crypto.randomUUID() in your browser.
- Oracle Java documentation, Class UUID, docs.oracle.com
- MDN Web Docs, Crypto: randomUUID() method, developer.mozilla.org
Frequently asked questions
Do I need a Maven or Gradle dependency for UUIDs in Java?
No. java.util.UUID is part of the Java standard library (core Java since Java 5). No external dependency required.
How do I compare two UUIDs in Java?
Use .equals(), not ==. UUID overrides equals() to compare by value, the same way you’d compare any object in Java.