Is UUID always 36 characters?

    April 10, 2025
    3 min read
    uuid
    formatting
    explainer
    standards

    If you’ve worked with UUIDs, you’ve probably seen strings like this:

    code
    550e8400-e29b-41d4-a716-446655440000

    That’s 36 characters long. So, is a UUID always 36 characters?

    Let’s break it down.


    🔢 The Standard UUID Format

    UUIDs are 128-bit values, which equals 16 bytes of raw data. But they’re often displayed in a textual format for readability and interoperability.

    The common string representation is:

    • 32 hexadecimal digits
    • 4 hyphens separating 5 groups

    Example:

    code
    550e8400-e29b-41d4-a716-446655440000

    That’s 36 characters total:

    • 32 hex characters
    • 4 hyphens

    This is the canonical representation defined in [RFC 4122](https://datatracker.ietf.org/doc/html/rfc4122).

    ✂️ What If You Remove the Hyphens?

    Just the raw hex value is 32 characters long:

    code
    550e8400e29b41d4a716446655440000

    Same UUID, just formatted differently.

    🧪 Python example:

    python
    import uuid
    u = uuid.uuid4()
    print(str(u))           # 36 characters (with hyphens)
    print(u.hex)            # 32 characters (no hyphens)

    💾 Binary and Base64 Encodings

    Remember, UUIDs are fundamentally 128-bit (16-byte) values. Depending on how they’re stored or transmitted, they might be:

    • 16 bytes in binary form
    • 22 characters in Base64 (URL-safe)
    • 36 characters in standard string form

    This has implications for storage, especially in databases or URL design.

    Example:

    python
    import base64
    
    u = uuid.uuid4()
    base64_url = base64.urlsafe_b64encode(u.bytes).rstrip(b'=')
    print(base64_url.decode())  # ~22 chars, URL-safe

    🧠 Why Does This Matter?

    While UUIDs are universally 128 bits in structure, how they're represented can affect:

    • Storage efficiency (e.g. databases)
    • URL readability
    • API design

    Don’t assume a UUID will always be 36 characters—only the canonical string version is.

    ✅ Final Thoughts

    • UUIDs are 128-bit identifiers
    • Standard string form = 36 characters
    • Raw hex = 32 characters
    • Encoded forms like Base64 = ~22 characters

    So next time someone asks “Is a UUID always 36 characters?” you can confidently say:

    “Only when printed as a standard string—with hyphens.”


    Want to see how different UUID formats affect database indexing or network payload size? Stay tuned for our upcoming article on UUID performance tips!

    Generate Your Own UUIDs

    Ready to put this knowledge into practice? Try our UUID generators:

    Generate a Single UUID

    Create a UUID with our fast, secure generator

    Bulk UUID Generator

    Need multiple UUIDs? Generate them in bulk

    Summary

    This article explains the structure of UUIDs, why they are typically 36 characters long, and what causes variations in length across different formats or encodings.

    TLDR;

    A UUID is usually displayed as a 36-character string, including hyphens, but this can vary depending on formatting or encoding.

    Key points to remember:

    • Standard UUID strings (hex + hyphens) are 36 characters
    • Raw UUIDs are 16 bytes (128 bits), which may appear shorter in hex or Base64

    UUID length is about representation—not actual uniqueness or structure.

    Cookie Consent

    We use cookies to enhance your experience on our website. By accepting, you agree to the use of cookies in accordance with our Privacy Policy.