shortuuid: Generate Concise, Unambiguous, and URL-Safe UUIDs in Python
This repository profile is provided by osrepos.com, an open source repository discovery platform.

Summary
shortuuid is a Python library designed to generate concise, unambiguous, and URL-safe UUIDs. It addresses the need for non-sequential IDs that are easy for users to read and use, by translating standard UUIDs to a base57 alphabet. This library ensures IDs are short, readable, and avoids similar-looking characters like 'l', '1', 'I', 'O', and '0'.
Repository Information
Topics
Click on any tag to explore related repositories
Use at your own risk
OSRepos shares public repositories for knowledge and discovery only. Any installation, execution, configuration, or use of code from these repositories is the user's own responsibility. Always review the repository, source code, dependencies, licenses, and security implications before running or installing anything. OSRepos is not responsible for issues, damages, or losses resulting from third-party repositories.
Introduction
shortuuid is a straightforward Python library that generates concise, unambiguous, and URL-safe UUIDs. It's particularly useful when you need non-sequential IDs that are visible to users and must be as short and easy to use as possible. The library achieves this by taking standard UUIDs, generated by Python's built-in uuid module, and translating them into a base57 representation. This base57 alphabet uses lowercase and uppercase letters and digits, carefully excluding characters that can be easily confused, such as 'l', '1', 'I', 'O', and '0'.
Installation
To install shortuuid, you will need Python 3.6+.
There are several installation options:
- With pip (preferred): Run
pip install shortuuid. - With setuptools: Run
easy_install shortuuid. - From source: Download the source from the GitHub repository and run
python setup.py install.
Examples
Here's how to use shortuuid in your projects:
Basic UUID Generation:
>>> import shortuuid
>>> shortuuid.uuid()
'vytxeTZskVKR7C7WgdSP3d'
Version 5 UUIDs with Namespaces:
>>> shortuuid.uuid(name="example.com")
'exu3DTbj2ncsn9tLdLWspw'
>>> shortuuid.uuid(name="<http://example.com>")
'shortuuid.uuid(name="<http://example.com>")'
Generating Random Strings:
>>> shortuuid.ShortUUID().random(length=22)
'RaF56o2r58hTKT7AYS9doj'
Inspecting and Setting the Alphabet:
>>> shortuuid.get_alphabet()
'23456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
>>> shortuuid.set_alphabet("aaaaabcdefgh1230123")
>>> shortuuid.uuid()
'0agee20aa1hehebcagddhedddc0d2chhab3b'
Encoding and Decoding Existing UUIDs:
>>> import uuid
>>> u = uuid.uuid4()
>>> u
UUID('6ca4f0f8-2508-4bac-b8f1-5d1e3da2247a')
>>> s = shortuuid.encode(u)
>>> s
'MLpZDiEXM4VsUryR9oE8uc'
>>> shortuuid.decode(s) == u
True
Class-based Usage for Multiple Alphabets:
>>> su = shortuuid.ShortUUID(alphabet="01345678")
>>> su.uuid()
'034636353306816784480643806546503818874456'
Command-line Usage:
$ shortuuid
fZpeF6gcskHbSpTgpQCkcJ
Django Field Integration:
shortuuid also provides a Django field for convenience, allowing you to easily integrate short UUIDs into your models:
from shortuuid.django_fields import ShortUUIDField
class MyModel(models.Model):
id = ShortUUIDField(
length=16,
max_length=40,
prefix="id_",
alphabet="abcdefg1234",
primary_key=True,
)
api_key = ShortUUIDField()
Why Use It
shortuuid offers a compelling solution for generating identifiers that are both unique and user-friendly. Its core advantage lies in producing concise, unambiguous, and URL-safe IDs, which significantly improves readability and usability in contexts where IDs are exposed to users. By meticulously removing similar-looking characters from its alphabet, it minimizes confusion and errors. The library's flexibility, allowing custom alphabets and length truncation, makes it adaptable to various project requirements. Furthermore, its seamless integration with Django provides an easy way to incorporate these benefits into web applications.
Links
- GitHub Repository: https://github.com/skorokithakis/shortuuid
Related repositories
Similar repositories that may be relevant next.

oh-my-hermes: Enhance Hermes Agent with Advanced AI Workflow and Memory
September 17, 2026
oh-my-hermes is an all-in-one plugin designed to significantly enhance the Hermes Agent. It provides advanced coding intelligence, a robust long-term memory system, and optimized workflow packages, transforming standard Hermes requests into structured, actionable tasks with clear operational layers.
ASC: A Super Fast Android Decompiler for Mobile Reverse Engineering
September 17, 2026
ASC is an innovative and exceptionally fast Android decompiler front-end, specifically designed for mobile researchers and agents. It redefines traditional decompilation by directly querying compiled artifacts, offering on-demand code extraction and analysis without heavy preprocessing. This approach results in significantly reduced memory usage and lightning-fast performance, even on large APKs.

Open Index: A Deterministic Memory Layer for Your AI Agents
September 16, 2026
Open Index is a powerful tool for building domain-specific, accurate, and structured data that AI agents can effectively operate on. It enables the creation of a "brain," a searchable and continuously improving context graph tailored to any domain. This system ensures agents have access to reliable, up-to-date information, enhancing their capabilities and decision-making processes.
tooltrim: Drastically Reduce LLM Agent Tool Output Tokens, Improve Accuracy
September 16, 2026
tooltrim provides drop-in compression for LLM agent tool outputs, drastically cutting tokens while often improving answer accuracy. This provider-agnostic solution offers content-aware compression, faithfulness benchmarks, and seamless integration with popular frameworks or as an OpenAI-compatible proxy.
Source repository
Open the original repository on GitHub.
23 counted GitHub visits