uuid-gen-cli
v1.0.0
Published
UUID Generator CLI with multiple options
Maintainers
Readme
🎲 UUID Generator CLI
A powerful and beautiful command-line tool for generating UUIDs with extensive formatting options and multiple UUID versions support.
✨ Features
- 🎯 Multiple UUID Versions - v1, v3, v4, v5, NIL, and custom formats
- 🎨 Flexible Formatting - Uppercase, no dashes, braces, prefix/suffix
- 📋 Clipboard Support - Automatically copy generated UUIDs
- 💾 Multiple Export Formats - TXT, JSON, CSV, SQL
- ⚡ Bulk Generation - Generate thousands of UUIDs efficiently
- ✅ UUID Validation - Validate and analyze existing UUIDs
- 🌈 Beautiful CLI Output - Colorful, formatted terminal display
- 🔧 Customizable - Create UUIDs with custom templates
📦 Installation
Prerequisites
- Node.js 16.x or higher
- npm or yarn
Local Installation
Global Installation
npm install -g uuid-gen-cli🚀 Quick Start
# Generate a single UUID v4 (most common)
uuid-gen v4
# Generate 10 UUIDs
uuid-gen v4 -c 10
# Generate and copy to clipboard
uuid-gen v4 --copy
# Generate 5 uppercase UUIDs without dashes
uuid-gen v4 -c 5 --uppercase --no-dashes
# Validate a UUID
uuid-gen validate 550e8400-e29b-41d4-a716-446655440000📖 Usage
Basic Syntax
uuid-gen <command> [options]Available Commands
| Command | Description |
|---------|-------------|
| v1 | Generate time-based UUID (version 1) |
| v4 | Generate random UUID (version 4) - Most common |
| v3 <name> | Generate MD5 hash-based UUID (version 3) |
| v5 <name> | Generate SHA-1 hash-based UUID (version 5) |
| nil | Generate NIL UUID (all zeros) |
| custom | Generate custom format UUID |
| bulk | Generate bulk UUIDs efficiently |
| validate <uuid> | Validate and analyze a UUID |
💡 Examples
UUID v4 (Random) - Most Common
# Single UUID
uuid-gen node index.js v4 -c 10
{ count: '10', dashes: true, format: 'txt' }
╔══════════════════════════════════════════════════════════╗
║ UUID v4 (Random) ║
╠══════════════════════════════════════════════════════════╣
║ Count: 10 ║
║ Format: lowercase ║
╚══════════════════════════════════════════════════════════╝
01. b48e69ad-172e-4115-9c17-6050950d4d2d
02. 7804c62a-ecd7-4651-a8b6-b8775b9c1bc3
03. f8fa281d-948c-4328-9f37-8b31182a12d2
04. 03179ba0-5b2c-4487-8d19-49fa750d98db
05. 538b371b-c441-4aea-81a4-827253abe6b5
06. 089c8898-e8bd-4b25-8b78-2ab24a937572
07. 41cdee5c-1351-4e9c-8685-9339174ae062
08. a626c539-acd4-42f5-9a34-1881f59bd8e2
09. 2dc321f5-decb-4481-9ac3-13814f9340ab
10. 229f7e87-a473-4ee6-b5f7-b4b14fa01358
# Generate 10 UUIDs
uuid-gen v4 -c 10
# Generate 5 uppercase UUIDs
uuid-gen v4 -c 5 --uppercase
# Generate without dashes
uuid-gen v4 -c 3 --no-dashes
# Generate with braces
uuid-gen v4 -c 3 --braces
# Output: {7c9e6679-7425-40de-944b-e07fc1f90ae7}
# Generate with prefix and suffix
uuid-gen v4 -c 5 --prefix "USER-" --suffix "-ID"
# Output: USER-7c9e6679-7425-40de-944b-e07fc1f90ae7-ID
# Copy to clipboard
uuid-gen v4 --copyUUID v1 (Time-based)
# Generate time-based UUID
uuid-gen v1
# Generate 5 time-based UUIDs
uuid-gen v1 -c 5
# Time-based with formatting
uuid-gen v1 -c 3 --uppercase --bracesUUID v5 (Hash-based with Name)
# Generate UUID from domain name
uuid-gen v5 "example.com"
# Using different namespaces
uuid-gen v5 "example.com" --namespace dns
uuid-gen v5 "https://example.com" --namespace url
uuid-gen v5 "mydata" --namespace oid
# Generate multiple with incrementing names
uuid-gen v5 "user" -c 5
# Output: user-0, user-1, user-2, user-3, user-4
# Custom namespace UUID
uuid-gen v5 "mydata" --namespace "6ba7b810-9dad-11d1-80b4-00c04fd430c8"UUID v3 (MD5 Hash-based)
# Similar to v5 but uses MD5 instead of SHA-1
uuid-gen v3 "example.com" --namespace dns
uuid-gen v3 "mydata" -c 5NIL UUID
# Generate NIL UUID (all zeros)
uuid-gen nil
# Output: 00000000-0000-0000-0000-000000000000Custom Format
# Custom format template (x = random hex, y = variant bits)
uuid-gen custom --format "xxxx-xxxx-xxxx" -c 5
# Custom length
uuid-gen custom --format "xxxxxxxx" -c 3
# Complex custom format
uuid-gen custom --format "xxxx-yyyy-xxxx-yyyy" -c 5 --uppercaseBulk Generation
# Generate 10,000 UUIDs
uuid-gen bulk -c 10000 -o uuids.txt
# Generate 5,000 uppercase UUIDs without dashes
uuid-gen bulk -c 5000 --uppercase --no-dashes -o uuids.txt
# Generate bulk as JSON
uuid-gen bulk -c 1000 -o uuids.json --format json
# Generate bulk as CSV
uuid-gen bulk -c 2000 -o uuids.csv --format csv
# Generate bulk as SQL
uuid-gen bulk -c 500 -o uuids.sql --format sqlSave to File
# Save as text file
uuid-gen v4 -c 100 --file uuids.txt
# Save as JSON
uuid-gen v4 -c 50 --file uuids.json --format json
# Save as CSV
uuid-gen v4 -c 200 --file uuids.csv --format csv
# Save as SQL values
uuid-gen v4 -c 100 --file uuids.sql --format sqlValidate UUID
# Validate and analyze a UUID
uuid-gen validate 550e8400-e29b-41d4-a716-446655440000
# Output:
# ╔══════════════════════════════════════════════════════════╗
# ║ UUID Analysis ║
# ╠══════════════════════════════════════════════════════════╣
# ║ UUID: 550e8400-e29b-41d4-a716-446655440000 ║
# ║ Valid: ✓ YES ║
# ║ Version: 4 ║
# ║ Variant: 1010 ║
# ║ Type: Random ║
# ╚══════════════════════════════════════════════════════════╝
# Validate invalid UUID
uuid-gen validate "not-a-uuid"🎛️ Options
Common Options (Available for Most Commands)
| Option | Short | Description | Default |
|--------|-------|-------------|---------|
| --count <n> | -c | Number of UUIDs to generate | 1 |
| --uppercase | -u | Output in uppercase | false |
| --no-dashes | -n | Remove dashes from output | false |
| --braces | -b | Wrap UUID in braces {} | false |
| --prefix <text> | -p | Add prefix to each UUID | - |
| --suffix <text> | -s | Add suffix to each UUID | - |
| --file <path> | -f | Save to file | - |
| --format <type> | | File format (txt, json, csv, sql) | txt |
| --copy | | Copy first UUID to clipboard | false |
Version-Specific Options
v3 and v5 Options
| Option | Description | Default |
|--------|-------------|---------|
| --namespace <ns> | Namespace (dns, url, oid, x500, or UUID) | dns |
Bulk Options
| Option | Description |
|--------|-------------|
| --version <v> | UUID version (v1, v4, random) |
| --output <path> | Output file path (required) |
Custom Options
| Option | Description | Default |
|--------|-------------|---------|
| --format <template> | Custom format template | xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx |
📁 File Formats
Text Format (default)
7c9e6679-7425-40de-944b-e07fc1f90ae7
3d813cbb-47fb-42eb-89e3-5b6d9d2b1f85
9c5e1f0a-8d4c-4a7e-9f3b-2e1d6c8b9a0fJSON Format
[
"7c9e6679-7425-40de-944b-e07fc1f90ae7",
"3d813cbb-47fb-42eb-89e3-5b6d9d2b1f85",
"9c5e1f0a-8d4c-4a7e-9f3b-2e1d6c8b9a0f"
]CSV Format
uuid
7c9e6679-7425-40de-944b-e07fc1f90ae7
3d813cbb-47fb-42eb-89e3-5b6d9d2b1f85
9c5e1f0a-8d4c-4a7e-9f3b-2e1d6c8b9a0fSQL Format
'7c9e6679-7425-40de-944b-e07fc1f90ae7',
'3d813cbb-47fb-42eb-89e3-5b6d9d2b1f85',
'9c5e1f0a-8d4c-4a7e-9f3b-2e1d6c8b9a0f'🔍 UUID Versions Explained
UUID v1 (Time-based)
- Generated from current timestamp and MAC address
- Guaranteed to be unique (given same machine)
- Reveals timestamp and location information
- Use case: When you need time-ordered UUIDs
UUID v4 (Random)
- Generated from random numbers
- Most commonly used version
- No information leakage
- Use case: General purpose, most applications
UUID v3 (MD5 Hash)
- Generated from namespace and name using MD5
- Deterministic (same input = same UUID)
- Use case: When you need reproducible UUIDs
UUID v5 (SHA-1 Hash)
- Generated from namespace and name using SHA-1
- Deterministic (same input = same UUID)
- More secure than v3
- Use case: When you need reproducible UUIDs with better security
NIL UUID
- All zeros:
00000000-0000-0000-0000-000000000000 - Use case: Placeholder, default value
🎨 Output Examples
Standard Output
╔══════════════════════════════════════════════════════════╗
║ UUID v4 (Random) ║
╠══════════════════════════════════════════════════════════╣
║ Count: 5 ║
║ Format: lowercase ║
╚══════════════════════════════════════════════════════════╝
01. 7c9e6679-7425-40de-944b-e07fc1f90ae7
02. 3d813cbb-47fb-42eb-89e3-5b6d9d2b1f85
03. 9c5e1f0a-8d4c-4a7e-9f3b-2e1d6c8b9a0f
04. 2f8b3a1c-5d9e-4f7a-8c6b-1e4d7a9f3b2c
05. 8a7f6e5d-4c3b-4a29-9f8e-7d6c5b4a3f2eBulk Generation Progress
🚀 Generating bulk UUIDs...
Progress: 1000/10000
Progress: 2000/10000
...
Progress: 10000/10000
✓ Saved 10000 UUIDs to: uuids.txt
✓ Generated 10000 UUIDs🔧 Advanced Usage
Combining Multiple Options
# Generate 100 uppercase UUIDs with braces, save as JSON
uuid-gen v4 -c 100 --uppercase --braces --file output.json --format json
# Generate UUIDs with custom prefix/suffix and save
uuid-gen v4 -c 50 --prefix "ID_" --suffix "_END" --file ids.txt
# Generate bulk with all formatting
uuid-gen bulk -c 5000 --uppercase --no-dashes -o output.csv --format csvUsing in Scripts
#!/bin/bash
# Generate UUID and use in script
UUID=$(uuid-gen v4 | grep -o '[a-f0-9-]\{36\}')
echo "Generated UUID: $UUID"
# Create 100 user IDs
uuid-gen v4 -c 100 --prefix "USER_" --file user_ids.txt
# Generate database insert statements
uuid-gen v4 -c 1000 --file uuids.sql --format sqlIntegration Examples
Shell Script
# Generate and use UUID
NEW_ID=$(uuid-gen v4 --copy)
echo "Created new ID: $NEW_ID"Python Integration
import subprocess
# Generate UUID using CLI
result = subprocess.run(['uuid-gen', 'v4'], capture_output=True, text=True)
uuid = result.stdout.strip().split('\n')[-1].strip()
print(f"Generated UUID: {uuid}")Node.js Integration
const { execSync } = require('child_process');
// Generate UUID
const uuid = execSync('uuid-gen v4').toString().trim().split('\n').pop();
console.log(`Generated UUID: ${uuid}`);🐛 Troubleshooting
Issue: "Cannot copy to clipboard"
Solution: Clipboardy requires additional dependencies on Linux
sudo apt-get install xclip # Ubuntu/Debian📊 Performance
- Single UUID: ~1ms
- 100 UUIDs: ~5ms
- 1,000 UUIDs: ~50ms
- 10,000 UUIDs: ~500ms
- 100,000 UUIDs: ~5s
Bulk generation uses batching for optimal performance.
📝 License
This project is licensed under the MIT License.
👤 Author
- Mohan Chinnappan
📚 Resources
🔮 Future Enhancements
- [ ] UUID v6 and v7 support (draft specification)
- [ ] Interactive mode with prompts
- [ ] UUID comparison tool
- [ ] Batch validation from file
- [ ] Web interface
- [ ] REST API mode
- [ ] Database integration helpers
- [ ] More output formats (XML, YAML)
Made with ❤️ for the UUID community
