idgen
A lightweight command-line utility for generating and inspecting various types of unique identifiers:
- UUID (versions 1, 3, 4, and 5)
- NanoID
- CUID (versions 1 and 2)
- ULID
- MongoDB ObjectID
This tool is designed for developers who need to generate or analyze various types of IDs during development, testing, debugging, or data migration.
Table of Contents
- idgen
Features
- Generate UUIDs with support for all major versions (v1, v3, v4, v5)
- Create MongoDB-style ObjectIDs
- Generate URL-safe NanoIDs with configurable length
- Generate CUIDs (v1 and v2)
- Generate ULIDs
- Inspect and identify unknown IDs (detect type, version, and embedded timestamps)
- Multiple output formats (simple, hyphenated, URN)
- JSON output for scripting and automation
- Support for batch generation
- Custom prefix and suffix support
- Shell completions for bash, zsh, fish, and PowerShell
- Man page generation for Unix-like systems
- Banner-free mode by default (script-friendly)
Installation
From crates.io (Recommended)
Pre-built Binaries
Download the latest release for your platform from GitHub Releases:
| Platform | Download |
|---|---|
| Linux (x64) | idgen-linux-amd64 |
| macOS (x64) | idgen-macos-amd64 |
| Windows (x64) | idgen-windows-amd64.exe |
# Linux/macOS: Make executable and move to PATH
# Windows: Move to a directory in your PATH
Build from Source
- Install Rust if not already installed
- Build from source:
- Copy binary to your PATH:
# Linux/macOS # Windows (PowerShell, adjust path as needed)
Quick Start
Generate a random UUID (v4):
Generate with banner:
Generate multiple IDs:
Real-World Scenarios
Manual Database Inserts & Seeding
Quickly generate IDs for manual SQL INSERT statements or when creating seed data files (CSV/JSON) for development databases.
# Generate 5 UUIDs for a seed file
API Testing & Development
Generate unique IDs on the fly when testing APIs with curl or Postman, especially for endpoints that require a unique request_id or transaction_id.
# Use in a curl request
Scripting & Automation
Use in CI/CD pipelines or shell scripts to generate unique filenames, deployment tags, or temporary resource identifiers.
# Create a unique temporary file
Configuration & Secrets
Generate unique strings for configuration files, such as JWT_SECRET, API_KEY, or session secrets during project setup.
# Generate a strong, random secret
Verification & Debugging
Verify the output of deterministic IDs (like UUID v5) to ensure your application logic matches the standard.
# Verify UUID v5 generation
Distributed Tracing
Generate a unique trace ID to manually tag a request flow across microservices when debugging.
# Generate a trace ID (UUID v4)
Mock Data Generation
Generate IDs for JSON mock files used in frontend development.
# Generate 10 NanoIDs for a mock user list
# Generate mock email addresses
Cloud Resource Naming
Generate unique tags for cloud resources (AWS/Azure/GCP) during manual provisioning or Terraform/Ansible runs.
# Generate a unique suffix for an S3 bucket
|
Debugging & Inspection
Analyze unknown IDs found in logs or databases to determine their type, version, and creation timestamp (if available).
# Inspect an ID to see what it is
# Check if an ID is valid with JSON output
ID Types and Use Cases
UUID (Universal Unique Identifier)
Standard 128-bit identifiers with multiple versions for different needs:
UUID v1 (Time-based)
- Format: Timestamp + node ID based
- Example:
550e8400-e29b-11d4-a716-446655440000 - Best for: Logging, temporal ordering, distributed systems
UUID v4 (Random)
- Format: Random numbers
- Example:
550e8400-e29b-44d4-a716-446655440000 - Best for: Default choice, database keys, session IDs
UUID v3/v5 (Name-based)
- v3 uses MD5, v5 uses SHA-1 (preferred)
- Example:
cfbff0d1-9375-5685-968c-48ce8b15ae17 - Best for: Consistent IDs from same input, content addressing
MongoDB ObjectID
12-byte identifier combining timestamp, machine ID, and counter:
- Example:
507f1f77bcf86cd799439011 - Best for: Document IDs, chronological sorting
NanoID
Compact, URL-safe identifiers:
- Example:
V1StGXR8_Z5jdHi6B-myT - Best for: Short URLs, user-facing IDs, frontend generation
CUID (Collision-resistant Unique Identifier)
Designed for horizontal scaling and performance:
- v1: Original version
- v2: Secure, collision-resistant, optimized for modern web
- Best for: High-performance distributed systems
ULID (Universally Unique Lexicographically Sortable Identifier)
Sortable, random, 128-bit identifier:
- Example:
01ARZ3NDEKTSV4RRFFQ69G5FAV - Best for: Database keys where sorting is important
Usage Guide
Command Options
Generate and inspect unique identifiers
Usage: idgen.exe [OPTIONS] [COMMAND]
Commands:
inspect Inspect an ID to determine its type and extract metadata
completions Generate shell completions
help Print this message or the help of the given subcommand(s)
Options:
-t, --type <ID_TYPE> Type of ID to generate [default: uuid4] [possible values: uuid1, uuid3, uuid4, uuid5, nanoid, cuid1, cuid2, ulid, objectid]
-f, --format <FORMAT> Output format for UUIDs [default: hyphenated] [possible values: hyphenated, simple, urn]
-c, --count <COUNT> Number of IDs to generate [default: 1]
-l, --length <LENGTH> Length for NanoID (default: 21)
-p, --prefix <PREFIX> Prefix to add to generated IDs [default: ]
-s, --suffix <SUFFIX> Suffix to add to generated IDs [default: ]
--namespace <NAMESPACE> Namespace UUID for v3/v5 (use DNS, URL, OID, X500, or a custom UUID)
--name <NAME> Name string for UUID v3/v5
--json Output as JSON
-b, --banner Show banner
-h, --help Print help (see more with '--help')
-V, --version Print version
EXAMPLES:
idgen Generate a random UUID v4 (default)
idgen -t uuid1 Generate a time-based UUID v1
idgen -t uuid3 --namespace DNS --name example.com
idgen -t nanoid -l 10 Generate a NanoID of length 10
idgen -t ulid Generate a ULID
idgen -c 5 Generate 5 UUIDs
idgen -p 'test-' -s '.log' Add prefix and suffix
idgen --json Output as JSON
idgen inspect 550e8400-e29b-44d4-a716-446655440000
idgen completions bash Generate bash completions
Format Options
Each ID can be formatted in different ways:
- Simple: No separators (
550e8400e29b44d4a716446655440000) - Hyphenated: Standard format (
550e8400-e29b-44d4-a716-446655440000) - URN: URN format (
urn:uuid:550e8400-e29b-44d4-a716-446655440000)
Examples
# Generate IDs (default: UUID v4)
# ID Types
# UUID Formats
# Multiple IDs
# Prefix and Suffix
# JSON Output
# Inspect IDs
# Shell Completions
# Man Page
Common UUID Namespaces
For UUID v3/v5, use these standard namespaces:
- DNS:
6ba7b810-9dad-11d1-80b4-00c04fd430c8 - URL:
6ba7b811-9dad-11d1-80b4-00c04fd430c8 - OID:
6ba7b812-9dad-11d1-80b4-00c04fd430c8 - X500:
6ba7b814-9dad-11d1-80b4-00c04fd430c8
Why idgen?
| Feature | idgen | uuidgen | uuid (npm) | nanoid (npm) |
|---|---|---|---|---|
| UUID v1-v5 | ✅ | ✅ | ✅ | ❌ |
| NanoID | ✅ | ❌ | ❌ | ✅ |
| CUID v1/v2 | ✅ | ❌ | ❌ | ❌ |
| ULID | ✅ | ❌ | ❌ | ❌ |
| ObjectID | ✅ | ❌ | ❌ | ❌ |
| ID Inspection | ✅ | ❌ | ❌ | ❌ |
| Shell Completions | ✅ | ❌ | ❌ | ❌ |
| Zero Runtime Deps | ✅ | ✅ | ❌ | ❌ |
| Single Binary | ✅ | ✅ | ❌ | ❌ |
Key advantages:
- All-in-one: Single tool for 9 ID types instead of multiple utilities
- ID Inspector: Unique feature to analyze and identify unknown IDs
- Fast: Native Rust binary with no interpreter overhead
- Portable: No Node.js, Python, or other runtime required
Contributing
We welcome contributions! Please feel free to submit a Pull Request. For major changes, open an issue first.
License
MIT License - Copyright © 2021-2025 ManiarTech®