Names

UUIDs

      Ctrl+Enter run / or Ctrl+K search tools Press Ctrl+D to bookmark this page

      How to generate UUIDs

      1. Choose a version. v4 is selected, and gives random UUIDs. Choose v7 for IDs that sort by time.
      2. Set how many you want, up to 10,000 at once, or press one of the quick counts. A fresh list appears straight away; press Generate or Ctrl+Enter for another.
      3. Pick a format: lowercase or uppercase, with or without hyphens, in braces or with a urn:uuid: prefix, with quotes and a separator. The list changes on the spot, without new UUIDs being made.
      4. Copy a single UUID from its row, or press Copy in the toolbar for the whole list. Copy and download as also gives a JSON array, a CSV column or an SQL IN (…) list.

      For v5 and v3, choose a name space and type one name per line. Each line gives its UUID as you type, and the same name always gives the same UUID.

      Reading a UUID

      A UUID is a 128-bit number, written as 32 hex digits in five groups of 8, 4, 4, 4 and 12: 017f22e2-79b0-7cc3-98c4-dc0c0c07398f.

      • The first digit of the third group is the version: 7 in the example.
      • The first digit of the fourth group holds the variant. For standard UUIDs it is 8, 9, a or b.
      • Everything else depends on the version: the time and random bits in v7, a hash in v5, random bits in v4.

      Upper and lower case mean the same thing. RFC 9562, the current UUID standard, allows both; this page writes lowercase unless you choose otherwise, as most libraries do. To check or take apart a UUID you already have, use the Validate and decode tab, or the UUID Validator.

      Which version to use

      VersionMade fromUse it for
      v4RandomThe default almost everywhere. Use it when an ID must not reveal anything, such as when it was made, and must not be guessable in order.
      v7Unix time + randomDatabase primary keys and anything you want sorted by creation time. New rows land at the end of the index instead of all over it.
      v5Name-based, SHA-1The same ID for the same thing every time, without storing a mapping: for example one ID per email address or URL.
      v3Name-based, MD5Only when an existing system expects version 3. Otherwise use v5.
      v1Time + nodeOlder systems, such as some Cassandra tables. Use v7 for new work: v1 does not sort as text and may contain the machine’s network address.
      v6Reordered timeA sortable form of v1, for systems that need v1 fields. RFC 9562 recommends v7 instead.
      v8CustomYour own layout. Only the version and variant are fixed, so nothing can be read from it without knowing who made it.
      NilAll zerosA placeholder meaning “no UUID”.
      MaxAll onesA placeholder, for example the upper end of a range.

      This page makes v4, v7, v5, v3, Nil and Max. The decoder reads all of them.

      v4 or v7 for database keys

      Random v4 keys arrive in no order, so each insert lands somewhere in the middle of the primary key index. On a large table that means more pages touched, more cache misses and more write-ahead log. A v7 UUID starts with the time in milliseconds, so new keys land at the end of the index, much like an auto-increment number, while still being unique across servers.

      The trade-off: anyone who sees a v7 UUID can read roughly when it was made. If that matters, for example for user IDs in public URLs, use v4.

      Keeping v7 in order within one millisecond

      Many UUIDs can be made in the same millisecond. To keep them in order, this page uses one of the methods RFC 9562 describes: the 12 bits after the time hold a counter. It starts at a random number below 2,048 in each new millisecond and goes up by one for each further UUID. If it runs out, the time moves on by one millisecond. If your computer’s clock jumps backwards, the page keeps using the last time, so the order still holds.

      This order is guaranteed for UUIDs made on this page during one visit. Other generators may fill the same bits with random numbers or a finer time, which the standard also allows, so do not rely on every v7 UUID sorting exactly in creation order.

      Set a time writes a time of your choice instead of now, which is useful for test data and backfilled records. Enter an ISO 8601 date and time such as 2025-03-14T09:30:00Z, or Unix milliseconds. A time without a zone is read as UTC.

      v5 and v3: UUIDs from names

      A name-based UUID is a hash of two things: a name space (itself a UUID) and a name. RFC 9562 defines four name spaces, for domain names, URLs, ISO object IDs and X.500 names; you can also use any UUID of your own, such as one made with v4 and kept for your app.

      Version 5 uses SHA-1 and version 3 uses MD5. The standard prefers v5. Neither can be turned back into the name, but anyone who knows the name space and guesses the name can work out the same UUID, so they are not a way to hide data.

      Names are read exactly as typed, in UTF-8: Example.com and example.com give different UUIDs, and so does a space at the end. The tool tells you when a name starts or ends with a space.

      UUID and GUID

      GUID is Microsoft’s name for a UUID. They are the same 128-bit format. Windows tools and .NET often show GUIDs in uppercase and in braces, like {919108F7-52D1-4320-9BAC-F847DB4148A8}; choose UPPERCASE and Braces to get that form. A GUID made by .NET’s Guid.NewGuid() is a version 4 UUID.

      Made in your browser

      Every UUID is made on your device with your browser’s cryptographically secure random number generator (crypto.getRandomValues), and v5 uses the browser’s own SHA-1. Nothing is requested from a server when you press Generate, and nothing is saved: not the UUIDs, not the names and not what you paste into the decoder. Only your format and version choices are kept in this browser, so the page opens the way you left it.

      Shared links carry your settings. They include the name space and names only if you tick that option. Everything goes after the #, which browsers never send to a server.

      Frequently asked questions

      Can two UUIDs ever be the same?

      In practice, no. A version 4 UUID has 122 random bits. You would need to make about 2.7 quintillion of them before there is even a 50% chance that any two match. Version 7 adds the time on top, so two can only match if they are made in the same millisecond. Version 5 and 3 UUIDs are meant to repeat: the same name space and name always give the same UUID.

      Can I use a UUID as a password, API key or reset token?

      No. RFC 9562 says UUIDs must not be used as security secrets. Version 7 reveals when it was made, version 5 can be recomputed by anyone who guesses the name, and many libraries do not use a secure random generator. For secrets, use a random token of at least 128 bits made for that purpose, such as one from a password generator.

      Are UUIDs case sensitive?

      No. Uppercase and lowercase hex digits mean the same value, and the standard allows both. Most libraries print lowercase, Microsoft tools often print uppercase. If you compare UUIDs as text, convert both to the same case first, or better, compare them as UUID or binary values.

      Should I store UUIDs with or without hyphens?

      In a database, store them in a native type if there is one (uuid in PostgreSQL, uniqueidentifier in SQL Server) or as 16 bytes (BINARY(16) in MySQL). That takes less than half the space of text and avoids any question of case and hyphens. In text, such as JSON and URLs, the standard form with hyphens is what other systems expect.

      Why does my validator reject v7 UUIDs?

      Some older validators only accept versions 1 to 5, because version 7 was standardised in May 2024 (RFC 9562). The UUID itself is fine. Update the library, or loosen the check to accept any version digit from 1 to 8.

      Can I get the name back from a v5 UUID?

      No. A version 5 UUID is part of a SHA-1 hash, which cannot be reversed. But anyone who knows the name space can hash a guessed name and compare, so do not use v5 to hide things like email addresses.

      Generating UUIDs in your code

      Making version 4, 5 and 7 UUIDs and checking the format, in Java, JavaScript, Python and Go, using only what each language ships with.

      Java

      // Version 4, 5, 3 and 7 UUIDs and a strict format check, with the JDK only.
      import java.nio.ByteBuffer;
      import java.nio.charset.StandardCharsets;
      import java.security.MessageDigest;
      import java.security.SecureRandom;
      import java.time.Instant;
      import java.util.UUID;
      
      public class UuidDemo {
          static final UUID NAMESPACE_DNS = UUID.fromString("6ba7b810-9dad-11d1-80b4-00c04fd430c8");
          static final SecureRandom RANDOM = new SecureRandom();
      
          // Versions 5 (SHA-1) and 3 (MD5): a hash of the name space bytes followed by the name.
          // UUID.nameUUIDFromBytes() makes version 3 too, but hashes only the bytes you pass,
          // so the name space must be put in front by hand.
          static UUID nameBased(String algorithm, int version, UUID namespace, String name) throws Exception {
              MessageDigest md = MessageDigest.getInstance(algorithm);
              md.update(toBytes(namespace));
              md.update(name.getBytes(StandardCharsets.UTF_8));
              byte[] h = md.digest();
              h[6] = (byte) ((h[6] & 0x0f) | (version << 4));
              h[8] = (byte) ((h[8] & 0x3f) | 0x80); // RFC 9562 variant
              ByteBuffer bb = ByteBuffer.wrap(h, 0, 16);
              return new UUID(bb.getLong(), bb.getLong());
          }
      
          static byte[] toBytes(UUID u) {
              return ByteBuffer.allocate(16)
                  .putLong(u.getMostSignificantBits())
                  .putLong(u.getLeastSignificantBits())
                  .array();
          }
      
          // Version 7: the Unix time in milliseconds (48 bits), then random bits.
          static UUID v7(long millis) {
              byte[] b = new byte[16];
              RANDOM.nextBytes(b);
              for (int i = 0; i < 6; i++) b[i] = (byte) (millis >>> (40 - 8 * i));
              b[6] = (byte) ((b[6] & 0x0f) | 0x70);
              b[8] = (byte) ((b[8] & 0x3f) | 0x80);
              ByteBuffer bb = ByteBuffer.wrap(b);
              return new UUID(bb.getLong(), bb.getLong());
          }
      
          // UUID.fromString() is lenient: it accepts "1-2-3-4-5". Check the shape first.
          static boolean isUuid(String s) {
              return s.matches("(?i)[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}");
          }
      
          public static void main(String[] args) throws Exception {
              UUID v4 = UUID.randomUUID();
              System.out.println("v4 version: " + v4.version());
              System.out.println("v5: " + nameBased("SHA-1", 5, NAMESPACE_DNS, "www.example.com"));
              System.out.println("v3: " + nameBased("MD5", 3, NAMESPACE_DNS, "www.example.com"));
      
              UUID v7 = v7(Instant.parse("2025-03-14T09:30:00Z").toEpochMilli());
              System.out.println("v7 starts with: " + v7.toString().substring(0, 15));
              System.out.println("v7 time: " + Instant.ofEpochMilli(v7.getMostSignificantBits() >>> 16));
      
              System.out.println("valid: " + isUuid("919108f7-52d1-4320-9bac-f847db4148a8") + " " + isUuid("1-2-3-4-5"));
              System.out.println("UUID.fromString(\"1-2-3-4-5\") gives " + UUID.fromString("1-2-3-4-5"));
          }
      }

      JDK only. UUID.randomUUID() makes version 4; versions 5 and 7 need the few lines shown. Java 21.

      JavaScript

      // Version 4, 5 and 7 UUIDs and a strict format check, with Node's built-in crypto.
      import { createHash, randomBytes, randomUUID } from 'node:crypto';
      
      const NAMESPACE_DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';
      const UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
      
      function format(bytes) {
        const hex = Buffer.from(bytes).toString('hex');
        return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
      }
      
      // Version 5: SHA-1 of the name space bytes followed by the name in UTF-8.
      function uuidV5(namespace, name) {
        const hash = createHash('sha1')
          .update(Buffer.from(namespace.replaceAll('-', ''), 'hex'))
          .update(name, 'utf8')
          .digest();
        hash[6] = (hash[6] & 0x0f) | 0x50; // version 5
        hash[8] = (hash[8] & 0x3f) | 0x80; // RFC 9562 variant
        return format(hash.subarray(0, 16));
      }
      
      // Version 7: the Unix time in milliseconds (48 bits), then random bits.
      // UUIDs made in the same millisecond are not ordered; add a counter if you need that.
      function uuidV7(ms = Date.now()) {
        const bytes = randomBytes(16);
        bytes.writeUIntBE(ms, 0, 6);
        bytes[6] = (bytes[6] & 0x0f) | 0x70; // version 7
        bytes[8] = (bytes[8] & 0x3f) | 0x80; // RFC 9562 variant
        return format(bytes);
      }
      
      const v4 = randomUUID(); // built in: Node 15.6+, and crypto.randomUUID() in browsers
      console.log('v4 version:', v4[14], 'valid:', UUID_PATTERN.test(v4));
      console.log('v5:', uuidV5(NAMESPACE_DNS, 'www.example.com'));
      
      const v7 = uuidV7(Date.UTC(2025, 2, 14, 9, 30));
      console.log('v7 starts with:', v7.slice(0, 15));
      console.log('v7 time:', new Date(parseInt(v7.replaceAll('-', '').slice(0, 12), 16)).toISOString());
      
      console.log('valid:', UUID_PATTERN.test('919108f7-52d1-4320-9bac-f847db4148a8'), UUID_PATTERN.test('919108f7-52d1-4320-9bac-f847db4148a'));

      Node’s built-in crypto module. In browsers, crypto.randomUUID() makes version 4 on secure (https) pages.

      Python

      # Version 4, 5, 3 and 7 UUIDs and a strict format check, with the standard uuid module.
      import os
      import time
      import uuid
      from datetime import datetime, timezone
      
      v4 = uuid.uuid4()
      print("v4 version:", v4.version)
      print("v5:", uuid.uuid5(uuid.NAMESPACE_DNS, "www.example.com"))
      print("v3:", uuid.uuid3(uuid.NAMESPACE_DNS, "www.example.com"))
      
      
      # Python 3.14 adds uuid.uuid7(). Before that, it takes a few lines:
      # the Unix time in milliseconds (48 bits), then random bits.
      def uuid7(ms=None):
          if ms is None:
              ms = time.time_ns() // 1_000_000
          b = bytearray(ms.to_bytes(6, "big") + os.urandom(10))
          b[6] = (b[6] & 0x0F) | 0x70  # version 7
          b[8] = (b[8] & 0x3F) | 0x80  # RFC 9562 variant
          return uuid.UUID(bytes=bytes(b))
      
      
      v7 = uuid7(1741944600000)  # 2025-03-14 09:30 UTC
      print("v7 starts with:", str(v7)[:15])
      written = datetime.fromtimestamp(int(v7.hex[:12], 16) / 1000, tz=timezone.utc)
      print("v7 time:", written.isoformat(timespec="milliseconds"))
      
      
      # uuid.UUID() also accepts braces, urn:uuid: and no hyphens.
      # Compare with the standard form to accept only 8-4-4-4-12.
      def is_uuid(text):
          try:
              return str(uuid.UUID(text)) == text.lower()
          except ValueError:
              return False
      
      
      print("valid:", is_uuid("919108f7-52d1-4320-9bac-f847db4148a8"), is_uuid("919108f7-52d1-4320-9bac-f847db4148a"))

      The uuid module in the standard library. Python 3.14 adds uuid.uuid7().

      Go

      // Version 4, 5 and 7 UUIDs and a strict format check, with the standard library.
      // Most projects use github.com/google/uuid instead: uuid.New(), uuid.NewV7(), uuid.NewSHA1().
      package main
      
      import (
      	"crypto/rand"
      	"crypto/sha1"
      	"fmt"
      	"regexp"
      	"time"
      )
      
      var namespaceDNS = [16]byte{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8}
      
      var uuidPattern = regexp.MustCompile(`^(?i)[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$`)
      
      func format(b [16]byte) string {
      	return fmt.Sprintf("%x-%x-%x-%x-%x", b[0:4], b[4:6], b[6:8], b[8:10], b[10:16])
      }
      
      // Version 4: 122 random bits.
      func newV4() [16]byte {
      	var b [16]byte
      	if _, err := rand.Read(b[:]); err != nil {
      		panic(err)
      	}
      	b[6] = b[6]&0x0f | 0x40 // version 4
      	b[8] = b[8]&0x3f | 0x80 // RFC 9562 variant
      	return b
      }
      
      // Version 5: SHA-1 of the name space bytes followed by the name.
      func newV5(namespace [16]byte, name string) [16]byte {
      	h := sha1.New()
      	h.Write(namespace[:])
      	h.Write([]byte(name))
      	var b [16]byte
      	copy(b[:], h.Sum(nil))
      	b[6] = b[6]&0x0f | 0x50
      	b[8] = b[8]&0x3f | 0x80
      	return b
      }
      
      // Version 7: the Unix time in milliseconds (48 bits), then random bits.
      func newV7(t time.Time) [16]byte {
      	var b [16]byte
      	if _, err := rand.Read(b[6:]); err != nil {
      		panic(err)
      	}
      	ms := uint64(t.UnixMilli())
      	for i := 0; i < 6; i++ {
      		b[i] = byte(ms >> (40 - 8*i))
      	}
      	b[6] = b[6]&0x0f | 0x70
      	b[8] = b[8]&0x3f | 0x80
      	return b
      }
      
      func main() {
      	v4 := format(newV4())
      	fmt.Println("v4 version:", string(v4[14]), "valid:", uuidPattern.MatchString(v4))
      	fmt.Println("v5:", format(newV5(namespaceDNS, "www.example.com")))
      
      	v7 := newV7(time.Date(2025, 3, 14, 9, 30, 0, 0, time.UTC))
      	fmt.Println("v7 starts with:", format(v7)[:15])
      	var ms uint64
      	for i := 0; i < 6; i++ {
      		ms = ms<<8 | uint64(v7[i])
      	}
      	fmt.Println("v7 time:", time.UnixMilli(int64(ms)).UTC().Format(time.RFC3339Nano))
      
      	fmt.Println("valid:", uuidPattern.MatchString("919108f7-52d1-4320-9bac-f847db4148a8"), uuidPattern.MatchString("919108f7-52d1-4320-9bac-f847db4148a"))
      }

      Standard library only: Go has no UUID package. Most projects use github.com/google/uuid.

      Last verified . Each example is run automatically and its output checked.

      Settings

      Deletes everything this site keeps in your browser: saved inputs, favorites, theme, accent color and tool options.