{"name":"shortuuid: Generate Concise, Unambiguous, and URL-Safe UUIDs in Python","description":"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'.","github":"https://github.com/skorokithakis/shortuuid","url":"https://osrepos.com/repo/skorokithakis-shortuuid","source":"osrepos.com","sourceDescription":"This repository profile is provided by osrepos.com, an open source repository discovery platform.","repositoryProfile":"https://osrepos.com/repo/skorokithakis-shortuuid","generatedFor":"open source discovery and AI-assisted research","markdown":"https://osrepos.com/repo/skorokithakis-shortuuid.md","json":"https://osrepos.com/repo/skorokithakis-shortuuid.json","topics":["Python","UUID","ID Generation","URL-Safe","Library","Django","Developer Tools"],"keywords":["Python","UUID","ID Generation","URL-Safe","Library","Django","Developer Tools"],"stars":null,"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'.","content":"## Introduction\n\n`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'.\n\n## Installation\n\nTo install `shortuuid`, you will need Python 3.6+.\n\nThere are several installation options:\n\n*   **With pip (preferred)**: Run `pip install shortuuid`.\n*   **With setuptools**: Run `easy_install shortuuid`.\n*   **From source**: Download the source from the [GitHub repository](https://github.com/skorokithakis/shortuuid) and run `python setup.py install`.\n\n## Examples\n\nHere's how to use `shortuuid` in your projects:\n\n**Basic UUID Generation:**\n\npython\n>>> import shortuuid\n>>> shortuuid.uuid()\n'vytxeTZskVKR7C7WgdSP3d'\n\n\n**Version 5 UUIDs with Namespaces:**\n\npython\n>>> shortuuid.uuid(name=\"example.com\")\n'exu3DTbj2ncsn9tLdLWspw'\n\n>>> shortuuid.uuid(name=\"<http://example.com>\")\n'shortuuid.uuid(name=\"<http://example.com>\")'\n\n\n**Generating Random Strings:**\n\npython\n>>> shortuuid.ShortUUID().random(length=22)\n'RaF56o2r58hTKT7AYS9doj'\n\n\n**Inspecting and Setting the Alphabet:**\n\npython\n>>> shortuuid.get_alphabet()\n'23456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'\n\n>>> shortuuid.set_alphabet(\"aaaaabcdefgh1230123\")\n>>> shortuuid.uuid()\n'0agee20aa1hehebcagddhedddc0d2chhab3b'\n\n\n**Encoding and Decoding Existing UUIDs:**\n\npython\n>>> import uuid\n>>> u = uuid.uuid4()\n>>> u\nUUID('6ca4f0f8-2508-4bac-b8f1-5d1e3da2247a')\n\n>>> s = shortuuid.encode(u)\n>>> s\n'MLpZDiEXM4VsUryR9oE8uc'\n\n>>> shortuuid.decode(s) == u\nTrue\n\n\n**Class-based Usage for Multiple Alphabets:**\n\npython\n>>> su = shortuuid.ShortUUID(alphabet=\"01345678\")\n>>> su.uuid()\n'034636353306816784480643806546503818874456'\n\n\n**Command-line Usage:**\n\nbash\n$ shortuuid\nfZpeF6gcskHbSpTgpQCkcJ\n\n\n**Django Field Integration:**\n\n`shortuuid` also provides a Django field for convenience, allowing you to easily integrate short UUIDs into your models:\n\npython\nfrom shortuuid.django_fields import ShortUUIDField\n\nclass MyModel(models.Model):\n    id = ShortUUIDField(\n        length=16,\n        max_length=40,\n        prefix=\"id_\",\n        alphabet=\"abcdefg1234\",\n        primary_key=True,\n    )\n    api_key = ShortUUIDField()\n\n\n## Why Use It\n\n`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.\n\n## Links\n\n*   **GitHub Repository**: [https://github.com/skorokithakis/shortuuid](https://github.com/skorokithakis/shortuuid)","metrics":{"detailViews":1,"githubClicks":1},"dates":{"published":null,"modified":"2026-07-31T00:23:46.000Z"}}