Proposal: Add a UUID Module to Elixir Standard Library

59 views
Skip to first unread message

Mohsen Nasiri

unread,
Apr 26, 2026, 4:40:06 PM (4 days ago) Apr 26
to elixir-lang-core
Hello Elixir Core Team,

I would like to propose adding a UUID module to the Elixir standard library.

Motivation
UUIDs are a widely adopted standard for generating unique identifiers in distributed systems, currently defined in RFC 9562 (which supersedes RFC 4122).

In Elixir, UUID functionality is available through external libraries such as Ecto or third-party packages, but there is no standardized, dependency-free implementation in the core language.

While UUID generation can be implemented using :crypto and existing libraries, there is currently no canonical, versioned, and officially supported implementation in Elixir itself, leading to divergence in behavior across ecosystem libraries.

This leads to:
  • Fragmentation in APIs across the ecosystem
  • Inconsistent implementations and behavior
  • Additional dependencies for a fundamental primitive
  • Reimplementation of a well-defined and stable standard

Current State
Common approaches include:
  • Ecto.UUID (requires Ecto dependency)
  • elixir-uuid, uniq (third-party implementations)
These solutions are functional but introduce coupling and API inconsistency across projects.

Prior Art
UUID support is included in many standard libraries:

Proposed Scope
A minimal UUID module in Elixir standard library: 

Core functionality
  • UUID generation (v4, v7)
  • Parsing and validation
  • String/binary conversion

Proposed API

# Generate UUIDs
UUID.generate() # Defaults to v4 (random)
UUID.generate(:v4) # Explicit version 4
UUID.generate(:v7) # Version 7 (time-ordered, sortable)

# Parse and format
{:ok, uuid} = UUID.parse("550e8400-e29b-41d4-a716-446655440000")
{:error, :invalid_format} = UUID.parse("not-a-uuid")

UUID.to_string(uuid) # "550e8400-e29b-41d4-a716-446655440000"
UUID.to_string(uuid, :urn) # "urn:uuid:550e8400-e29b-41d4-a716-446655440000"

# Validation
UUID.valid?("550e8400-e29b-41d4-a716-446655440000") # true
UUID.valid?("invalid") # false

# Version and variant inspection
UUID.version(uuid) # Returns version number (4, 7, etc.)
UUID.variant(uuid) # Returns :rfc4122


Version support
  • v4 (random): primary and most widely used case
  • v7 (time-ordered): recommended for modern distributed systems and database indexing
  • v1 (optional / deferred): due to privacy implications (MAC address exposure)
  • v3/v5 (optional): could be considered based on community demand 

Implementation Notes
  • Expected to rely on Erlang :crypto for randomness
  • No external dependencies
  • Pure stdlib implementation with stable API guarantees 

Benefits
  • Standardization across Elixir ecosystem
  • Reduced dependency overhead for common use cases
  • Improved interoperability between libraries and services
  • Better support for modern identifier patterns (especially UUIDv7)
  • Alignment with other mainstream languages

Conclusion
Given the ubiquity of UUIDs in modern systems, a standard UUID module in Elixir would provide a small but meaningful improvement to developer experience and ecosystem consistency without introducing significant complexity.

Thank you for considering this proposal.

Best regards,
Mohsen Nasiri

Andrea Leopardi

unread,
Apr 28, 2026, 12:35:19 PM (2 days ago) Apr 28
to elixir-l...@googlegroups.com
I vaguely remember this having been proposed before, but I’m generally in favor. I think UUID is here to stay and I've wished for it to be in the standard library many times.

However, I would strongly consider proposing this to the Erlang team instead. Having a uuid module in Erlang would mean being able to write native code for parts of this if necessary, for example. I think JSON support is a good precedent for this: Elixir added it to its stdlib once it could rely on a fast, robust implementation in the Erlang stdlib.

Andrea
--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.

Jon Rowe

unread,
Apr 28, 2026, 12:38:05 PM (2 days ago) Apr 28
to Elixir Lang Core
I agree with Andrea, it'd be great to have this upstream in Erlang to give us a homogenous implementation, I've also wanted this in the standard library a few times.

Regards
Jon

Christopher Keele

unread,
Apr 28, 2026, 1:21:54 PM (2 days ago) Apr 28
to elixir-lang-core
I second Andrea's opinions here as well.

Yordis Prieto

unread,
Apr 28, 2026, 1:26:49 PM (2 days ago) Apr 28
to elixir-lang-core
Definitely would like uuidv5, and I support what Andrea said; ideally, the Erlang team would add it.
Reply all
Reply to author
Forward
0 new messages