Generate UUID values (v4, v7) with flexible formatting, prefixes, suffixes, and output shape options.
Project description
uuid-kit
Generate UUID values (v4, v7) with flexible formatting, prefixes, suffixes, and output shape options.
Install
pip install uuid-kit
Usage
from uuid_kit import generate_uuid
result = generate_uuid(
count=3,
version="v7"
)
print(result)
Output
{
"version": "v7",
"format": "standard",
"output_as": "array",
"count": 3,
"items": [
"uuid-1",
"uuid-2",
"uuid-3"
]
}
Options
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| count | int | No | 1 | Number of UUIDs to generate |
| version | string | No | v7 | UUID version: v4 or v7 |
| format | string | No | standard | Output format: standard, compact, uppercase, uppercase-compact |
| prefix | string | No | "" | Text to prepend to each UUID |
| suffix | string | No | "" | Text to append to each UUID |
| outputAs | string | No | array | Output shape: array, object, or string |
Formats
| Format | Example |
|---|---|
| standard | 123e4567-e89b-12d3-a456-426614174000 |
| compact | 123e4567e89b12d3a456426614174000 |
| uppercase | 123E4567-E89B-12D3-A456-426614174000 |
| uppercase-compact | 123E4567E89B12D3A456426614174000 |
Examples
Default
generate_uuid(count=2)
Output:
{
"version": "v7",
"format": "standard",
"output_as": "array",
"count": 2,
"items": [
"uuid-1",
"uuid-2"
]
}
v4
generate_uuid(count=2, version="v4")
v7
generate_uuid(count=2, version="v7")
Compact format
generate_uuid(count=2, format="compact")
Uppercase compact with prefix and suffix
generate_uuid(
count=2,
format="uppercase-compact",
prefix="id_",
suffix="_end"
)
Object output
generate_uuid(count=2, outputAs="object")
Example output:
{
"version": "v7",
"format": "standard",
"output_as": "object",
"count": 2,
"items": [
{
"uuid": "123e4567-e89b-12d3-a456-426614174000",
"raw": "123e4567-e89b-12d3-a456-426614174000",
"index": 0,
"timestamp": {
"iso": "2026-04-09T18:00:00Z",
"unix": 1775757600000
}
},
{
"uuid": "123e4567-e89b-12d3-a456-426614174001",
"raw": "123e4567-e89b-12d3-a456-426614174001",
"index": 1,
"timestamp": {
"iso": "2026-04-09T18:00:00.001000Z",
"unix": 1775757600001
}
}
]
}
String output
generate_uuid(count=3, outputAs="string")
Example output:
{
"version": "v7",
"format": "standard",
"output_as": "string",
"count": 3,
"items": "uuid-1,uuid-2,uuid-3"
}
Output Shapes
outputAs="array"
Returns items as a list of formatted UUID strings.
outputAs="object"
Returns items as a list of objects.
Each object includes:
uuid= final formatted valueraw= original UUID before formattingindex= zero-based position in the result settimestamp= only included forv7whenoutputAs="object"
outputAs="string"
Returns items as a single comma-delimited string.
Supported Versions
v4= randomv7= time-based, sortable, recommended
Exports
from uuid_kit import generate_uuid
from uuid_kit import ALLOWED_FORMATS, ALLOWED_VERSIONS, ALLOWED_OUTPUT_AS
Behavior
- Invalid or missing
countdefaults to1 countis capped at100countis converted to an integer- Invalid or missing
versiondefaults tov7 - Invalid or missing
formatdefaults tostandard - Invalid or missing
outputAsdefaults toarray
Performance Notes
uuid-kit avoids unnecessary work during generation:
- Object records are only built when
outputAs="object" - Timestamps are only extracted for
v7object output - List storage is preallocated for efficient generation
This keeps array and string output paths lighter and faster.
Environment Notes
Some hosted Python runtimes require you to explicitly add packages before use. In those environments, add:
uuid-kit
uuid6
Notes
- Python standard library does not yet include native UUID v7 support
- To enable true v7 UUIDs, install:
pip install uuid6
- If
uuid6is not installed,version="v7"falls back internally and will not produce a true v7 UUID
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file uuid_kit-2.0.1.tar.gz.
File metadata
- Download URL: uuid_kit-2.0.1.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
085572ef3c0433d3d2897e15494b973eb70423a53d55415e65f1064a07855253
|
|
| MD5 |
1586d4f1a90ede528c7474c90a0d9fa0
|
|
| BLAKE2b-256 |
f7dd7d764e7f33a9fa64f9ba54a29e2c971f162e076ab285047f55ef47b1ff9a
|
File details
Details for the file uuid_kit-2.0.1-py3-none-any.whl.
File metadata
- Download URL: uuid_kit-2.0.1-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
330862034121925fb4c2faf01f37fb675e4d018ef0422b4abda9a471dada0e30
|
|
| MD5 |
f605ee6afbb4b82cdcaefd99cd86dd95
|
|
| BLAKE2b-256 |
b9da556e1de828242a3fa40616cde71912181d3e343c045433799c492ffe564f
|