Any other libraries to create UUIDv4 beside Ecto?

So I don’t depend on Ecto but I need a well maintained library to generate unique identifiers.

The only library other than ecto seems to be “elixir-uuid”, but it hasnt been updated in ages and when I use it I get many warnings because of deprecated stuff. I’ve checked the issues on Github and some of them even state that the generated UUIDs can sometimes be duplicated…

So the only other option I see is using Ecto.UUID… but I don’t want to import this huge library only to use the UUID functionality

Any ideas here?

My guess is that:

  1. Most projects already have ecto. Even if you aren’t using a database, its changesets, embedded schemas, and validators are useful.
  2. The rest just copy in the ~50 lines of code from here ecto/lib/ecto/uuid.ex at v3.11.2 · elixir-ecto/ecto · GitHub

Someone certainly could extract that to a library but it’s also just not that many lines of code, and they aren’t gonna change.


There are quite a few forks of the repo, you could look into those. Forks · zyro/elixir-uuid · GitHub

If a library hasn’t been updated in a while, maybe the author has moved on, I’ll also look at open pull requests to see if anyone has made the changes I need, and can move to that version. Pull requests · zyro/elixir-uuid · GitHub

If the changes I want haven’t been made, then I make them :slight_smile: yay open source!


There are other options like About — Uniq v0.6.1


I have also a reimplementation of elixir_uuid | Hex and uuid_utils | Hex . Not released yet, but if it can help I make a release. GitHub - hrzndhrn/ex_uuid: UUID generator according to RFC 4122


Also uuid_erl

1 Like

Yet another option (as an alternative to UUID, with the benefit of encoding a timestamp and thus being sortable by creation date): GitHub - omgnetwork/ex_ulid: Universally Unique Lexicographically Sortable Identifier (ULID) in Elixir


You can search for it using