# Python UUID libraries

Python UUID libraries generate universally unique identifiers beyond what the standard library's uuid module offers. A time-ordered UUID places a timestamp in its leading bits rather than filling every bit at random. These libraries let apps and databases create sortable identifiers that stay unique across machines.

## Popularity

| Library | Monthly downloads | Stars | Last release | License |
| --- | --- | --- | --- | --- |
| [uuid-utils](#uuid-utils) | 92.5M | 375 | Oct 2026 | BSD-3-Clause |
| [fastuuid](#fastuuid) | 85.4M | Not on GitHub | Oct 2025 | BSD-3-Clause |
| [shortuuid](#shortuuid) | 24.7M | 2.2K | Mar 2024 | BSD-3-Clause |
| [uuid6](#uuid6) | 11.4M | 182 | Jul 2025 | MIT |
| [uuid7-standard](#uuidseven-standard) | 318.0K | Not on GitHub | Sep 2026 | MIT OR Unlicense |

Downloads: pypi, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

[uuid-utils](#uuid-utils) has the most monthly downloads in this comparison, at 92.5M.

## Capabilities

| Library | Final-standard time-ordered UUIDs | Bulk random UUID generation | Custom alphabet codec | Explicit time argument |
| --- | --- | --- | --- | --- |
| [uuid-utils](#uuid-utils) | Yes | No | No | Yes |
| [fastuuid](#fastuuid) | Yes | Yes | No | No |
| [shortuuid](#shortuuid) | No | No | Yes | No |
| [uuid6](#uuid6) | Yes | No | No | No |
| [uuid7-standard](#uuidseven-standard) | Yes | No | No | Yes |

## Libraries

### uuid-utils

[GitHub](https://github.com/aminalaee/uuid-utils) · [pypi](https://pypi.org/project/uuid-utils) · [Docs](https://api.github.com/repos/aminalaee/uuid-utils/readme)

Provides Rust-backed UUID generation with an optional standard-library compatibility interface.

- Downloads / mo: 92.5M
- Stars: 375
- Last release: 1.2.0
- License: BSD-3-Clause
- Capabilities: [From the uuid-utils docs](https://api.github.com/repos/aminalaee/uuid-utils/readme)

**Strengths**

- **Provides random and named identifiers.** Generate random UUIDs or derive them from a name and namespace.
- **Returns standard-library objects through compatibility.** Use uuid_utils.compat when a framework requires standard-library UUID objects.

**Watch out for**

- **Default object types can conflict.** Switch to uuid_utils.compat for frameworks requiring standard-library UUID instances.

```sh
python -m pip install uuid-utils==1.2.0
```

**tensorzero/tensorzero** (11.7K stars)

[tensorzero/tensorzero](https://github.com/tensorzero/tensorzero) 

```python
def uuid7() -> UUID:
    """
    Generate a UUIDv7 using the uuid_utils compatibility layer.
    This ensures type compatibility with the rest of the TensorZero client.
    """
    return compat.uuid7()
```

[crates/tensorzero-python/tensorzero/util.py](https://github.com/tensorzero/tensorzero/blob/62eb8f63e8ec62018d70420dbf1a8c5d1c026315/crates/tensorzero-python/tensorzero/util.py#L6-L11) · [More projects using uuid-utils →](https://dashboard.exa.ai/playground/search?q=Python%20applications%20using%20uuid-utils%20for%20UUID%20generation%2C%20stable%20stream%20identifiers%2C%20timestamp%20adaptation%20and%20database%20fields&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```python
import uuid_utils

print(uuid_utils.uuid4())

```

From [README.md](https://api.github.com/repos/aminalaee/uuid-utils/readme)

### fastuuid

[GitHub](https://github.com/thedrow/fastuuid) · [pypi](https://pypi.org/project/fastuuid) · [Docs](https://api.github.com/repos/thedrow/fastuuid/readme)

Provides Python bindings to Rust's UUID library.

- Downloads / mo: 85.4M
- Last release: 0.14.0
- License: BSD-3-Clause
- Capabilities: [From the fastuuid docs](https://api.github.com/repos/thedrow/fastuuid/readme)

```sh
python -m pip install fastuuid==0.14.0
```

**Quickstart**

```python
import fastuuid

print(fastuuid.uuid4())

```

From [README.rst](https://api.github.com/repos/thedrow/fastuuid/readme) · [Find projects using fastuuid →](https://dashboard.exa.ai/playground/search?q=fastuuid%20GitHub%20projects)

### shortuuid

[GitHub](https://github.com/skorokithakis/shortuuid) · [pypi](https://pypi.org/project/shortuuid) · [Docs](https://api.github.com/repos/skorokithakis/shortuuid/readme)

Encodes UUIDs as compact strings using a customizable alphabet.

- Downloads / mo: 24.7M
- Stars: 2.2K
- Last release: 1.0.13
- License: BSD-3-Clause
- Capabilities: [From the shortuuid docs](https://api.github.com/repos/skorokithakis/shortuuid/readme)

**Strengths**

- **Produces compact readable identifiers.** The default alphabet removes similar-looking characters.
- **Converts existing UUIDs both ways.** Use encode and decode to round-trip an existing UUID.

**Watch out for**

- **Truncation discards identifier information.** Shortened strings lose the original UUID’s uniqueness properties.
- **Older encodings need legacy decoding.** Use legacy=True when decoding strings from the old encoding.

```sh
python -m pip install shortuuid==1.0.13
```

**django-extensions/django-extensions** (6.8K stars)

[django-extensions/django-extensions](https://github.com/django-extensions/django-extensions) 

```python
def create_uuid(self):
    if not self.version or self.version == 4:
        return shortuuid.uuid()
    elif self.version == 1:
        return shortuuid.uuid()
    elif self.version == 2:
        raise UUIDVersionError("UUID version 2 is not supported.")
    elif self.version == 3:
        raise UUIDVersionError("UUID version 3 is not supported.")
    elif self.version == 5:
        return shortuuid.uuid(name=self.namespace)
    else:
        raise UUIDVersionError("UUID version %s is not valid." % self.version)
```

[django_extensions/db/fields/__init__.py](https://github.com/django-extensions/django-extensions/blob/9bdf31556675e795c7c7c4f033f194dc075d5919/django_extensions/db/fields/__init__.py#L633-L645) · [More projects using shortuuid →](https://dashboard.exa.ai/playground/search?q=Python%20applications%20using%20shortuuid%20for%20UUID%20generation%2C%20stable%20stream%20identifiers%2C%20timestamp%20adaptation%20and%20database%20fields&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```python
import shortuuid

print(shortuuid.uuid())

```

From [README.md](https://api.github.com/repos/skorokithakis/shortuuid/readme)

### uuid6

[GitHub](https://github.com/oittaa/uuid6-python) · [pypi](https://pypi.org/project/uuid6) · [Docs](https://api.github.com/repos/oittaa/uuid6-python/readme)

Generates time-based UUIDs and converts legacy time-based UUIDs to reordered UUIDs.

- Downloads / mo: 11.4M
- Stars: 182
- Last release: 2025.0.1
- License: MIT
- Capabilities: [From the uuid6 docs](https://api.github.com/repos/oittaa/uuid6-python/readme)

**Strengths**

- **Generates time-ordered identifiers.** Use uuid7 for identifiers ordered by their timestamp.
- **Converts legacy UUIDs.** Use uuid1_to_uuid6 to reorder an existing version-one UUID.

**Watch out for**

- **Generation needs thread coordination.** Its time-based generation functions are not thread-safe.

```sh
python -m pip install uuid6==2025.0.1
```

**prowler-cloud/prowler** (15.3K stars)

[prowler-cloud/prowler](https://github.com/prowler-cloud/prowler) 

```python
def uuid7_range_bound(dt: datetime) -> UUID:
    """
    Returns the lowest UUIDv7 whose timestamp is the millisecond containing `dt`.

    Partition bounds have to be derived, not generated: two calls for the same
    instant must give the same literal, and consecutive windows must meet
    exactly. `datetime_to_uuid7` fills the sequence and node fields with
    randomness, which is right for an identifier and wrong for a bound -- a
    bound a millisecond wide with a random tail leaves the values above it in
    that millisecond outside every partition.

    The millisecond is counted with integer arithmetic rather than through
    `dt.timestamp() * 1000`: past year 2249 a float second no longer resolves a
    millisecond, so an instant in the last microsecond of one rounds up into the
    next, putting the bound a millisecond above the values it exists to include.

    Args:
        dt: The instant the bound sits at. A naive `dt` is read as local time,
            the same way `datetime.timestamp()` reads it.

    Returns:
        UUID: The smallest UUIDv7 in `dt`'s millisecond.
    """
    since_epoch = dt.astimezone(UTC) - datetime(1970, 1, 1, tzinfo=UTC)
    timestamp_ms = (since_epoch // timedelta(milliseconds=1)) & 0xFFFFFFFFFFFF
    # Version 7 in bits 76-79 and variant "10" in bits 62-63; every other bit zero.
    return UUID(int=(timestamp_ms << 80) | (0x7 << 76) | (0x2 << 62))
```

[api/src/backend/api/uuid_utils.py](https://github.com/prowler-cloud/prowler/blob/259c2930d04229ac8ef9bf20d70477c486ae1847/api/src/backend/api/uuid_utils.py#L35-L61) · [More projects using uuid6 →](https://dashboard.exa.ai/playground/search?q=Python%20applications%20using%20uuid6%20for%20UUID%20generation%2C%20stable%20stream%20identifiers%2C%20timestamp%20adaptation%20and%20database%20fields&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```python
from uuid6 import uuid7

print(uuid7())

```

From [README.md](https://api.github.com/repos/oittaa/uuid6-python/readme)

### uuid7-standard

[GitHub](https://github.com/LeoVasanko/uuid7-standard) · [pypi](https://pypi.org/project/uuid7-standard) · [Docs](https://api.github.com/repos/LeoVasanko/uuid7-standard/readme)

Pure Python UUIDv7 with datetime-based creation and timestamp extraction, filling gaps in stdlib and other implementations.

- Downloads / mo: 318.0K
- Last release: 1.1.2
- License: MIT OR Unlicense
- Capabilities: [From the uuid7-standard docs](https://api.github.com/repos/LeoVasanko/uuid7-standard/readme)

```sh
python -m pip install uuid7-standard==1.1.2
```

**Quickstart**

```python
import uuid7

print(uuid7.create())

```

From [README.md](https://api.github.com/repos/LeoVasanko/uuid7-standard/readme) · [Find projects using uuid7-standard →](https://dashboard.exa.ai/playground/search?q=uuid7-standard%20GitHub%20projects)

## FAQ

### Which Python UUID library should I use?

[uuid-utils](#uuid-utils) suits fast UUID generation, with a compatibility module for frameworks that need standard-library objects. [uuid6](#uuid6) suits time-ordered identifiers and conversion of legacy time-based UUIDs. [shortuuid](#shortuuid) suits compact, readable identifiers.

### How do I generate time-ordered UUIDs in Python?

[uuid6](#uuid6) generates identifiers ordered by their timestamp. Its time-based generation functions are not thread-safe.

### Is uuid-utils compatible with the standard uuid module?

Through uuid_utils.compat. That module returns standard-library UUID objects for frameworks that require them.

### What is shortuuid?

[shortuuid](#shortuuid) encodes UUIDs as compact strings with an alphabet that removes similar-looking characters. Its encode and decode functions round-trip an existing UUID.

## How this page was built

Data checked Nov 20, 2026.

Reproduce it with the Exa API:

```json
{
  "endpoint": "/search",
  "body": {
    "query": "Best Python UUID libraries uuid uuid6 uuid-utils shortuuid code examples",
    "numResults": 5
  }
}
```

Docs: https://exa.ai/docs/reference/search
