Skip to main content

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\nuuid-2\nuuid-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 value
  • raw = original UUID before formatting
  • index = zero-based position in the result set
  • timestamp = only included for v7 when outputAs="object"

outputAs="string"

Returns items as a single newline-delimited string.


Supported Versions

  • v4 = random
  • v7 = 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 count defaults to 1
  • count is capped at 100
  • count is converted to an integer
  • Invalid or missing version defaults to v7
  • Invalid or missing format defaults to standard
  • Invalid or missing outputAs defaults to array

Performance Notes

uuid-kit avoids unnecessary work during generation:

  • Object records are only built when outputAs="object"
  • Timestamps are only extracted for v7 object 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 uuid6 is 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

uuid_kit-2.0.2.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

uuid_kit-2.0.2-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file uuid_kit-2.0.2.tar.gz.

File metadata

  • Download URL: uuid_kit-2.0.2.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for uuid_kit-2.0.2.tar.gz
Algorithm Hash digest
SHA256 797948a16aad65ff56863dd82470c20408a9a4a8a68b1ca1735a76655ba23579
MD5 72a3fc282eb9081772ae7cd95b4498bc
BLAKE2b-256 9f155f82fdd5020e20e0039fe53c287c7f2c00af01973bafb18c73078c29b18c

See more details on using hashes here.

File details

Details for the file uuid_kit-2.0.2-py3-none-any.whl.

File metadata

  • Download URL: uuid_kit-2.0.2-py3-none-any.whl
  • Upload date:
  • Size: 5.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for uuid_kit-2.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f9ba13b502190988278c6ad31a8d6ecec0caee9a57bf77eb85a6d1314d7edf87
MD5 c494a93945064c427e9a112d413b66e5
BLAKE2b-256 20d6cdc191392c26d9c5d2fa90be3c9adf81c498d8bf5bfc3ab8a4102aa09855

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page