Comprehensive UUID library for Gleam
What is Dream UUID?
Dream UUID gives your app UUIDs it can count on. New ones sort in the order you made them, so your tables stay fast and your records stay in order. It accepts every valid UUID it's handed, including the rare kinds other systems sometimes produce, and gives it back exactly as it came. And it runs the same on the server and in the browser.
Features
Make IDs
Every version in the standard, with the right one a call away. Read more.
| Feature | What you get |
|---|---|
| 🕒 Time-ordered IDs | v7 IDs that sort in the order you made them, across every process on the node |
| 🎲 Random IDs | v4 from the system's secure random source |
| 🏷️ Same name, same ID | v3 and v5, with the four standard namespaces built in |
| 🧩 Your own layout | v8 for custom bits, and v1 and v6 for systems that still use them |
Read and print IDs
Text in any case, the URN form, and errors that say what's wrong. Read more.
| Feature | What you get |
|---|---|
| 🔤 Any case | Reads uppercase, lowercase and mixed text, and prints lowercase |
| 🔗 URN form | Reads and prints urn:uuid: text |
| 🧭 Exact errors | A parse error names the wrong length, or the character and where it is |
| 💾 Every UUID | Any 16 bytes are a UUID, and they come back unchanged |
Look inside an ID
The fields the standard defines, read straight from the bits. Read more.
| Feature | What you get |
|---|---|
| ⏱️ When it was made | The time of v1, v6 and v7 IDs, ready for gleam/time |
| 🔍 Version and layout | The version and the variant of any UUID |
| 🛠️ Built from fields | Make a UUID from its time, clock sequence, node or random parts |
Runs anywhere
The same API wherever Gleam runs. Read more.
| Feature | What you get |
|---|---|
| 🌐 Erlang and JavaScript | The same API on the BEAM, Node.js, Deno, Bun and browsers |
| 🤝 Works with youid | Convert to and from youid's Uuid without losing a bit |
| 📦 No dependencies | The Gleam standard library and nothing else |
A Quick Example
Make an ID and read one

import dream_uuid.{type ParseError, type Uuid, from_string, to_string, v7}
/// A new ID for a row, as text. Each new ID sorts after the one before it.
pub fn new_id() -> String {
v7() |> to_string
}
/// The ID in a request path, or why the text is not a UUID.
pub fn read_id(text: String) -> Result(Uuid, ParseError) {
from_string(text)
}
Run this: new_id() → a lowercase v7 ID such as "019378a2-5c1e-7d3b-9f20-4a6e8c1b2d3f", and the next call sorts after it.
Installation
gleam add dream_uuid
Guides
- Using Dream UUID: which version to use, the text forms, the fields, how v7 keeps its order,
gleam/time, youid and PostgreSQL
Requirements
- Gleam 1.19.2 or newer.
- On Erlang, the
cryptoapplication, which Dream UUID lists inextra_applications. - On JavaScript,
globalThis.crypto.getRandomValues: Node.js 19 or newer, Deno, Bun or a browser. - The tests run on the BEAM, because Dream Test runs on Erlang only for now. CI also compiles the package for JavaScript.
About Dream
Dream is a collection of Gleam packages for building production web applications. Each package implements its standards completely, shares the same naming and style as the others, and is fully tested. TrustBound builds Dream for its own production systems and shares it in the hope that it helps yours.
Dream UUID works on its own. You don't need the rest of Dream to use it.
Contributing
See CONTRIBUTING.md.