idgen-cli 1.4.0

A lightweight, powerful CLI tool for generating UUIDs (v1-v5), NanoIDs, CUIDs, ULIDs, and MongoDB ObjectIDs.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
# idgen


[![GitHub release](https://img.shields.io/github/v/release/maniartech/idgen)](https://github.com/maniartech/idgen/releases)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Rust Edition](https://img.shields.io/badge/Rust_Edition-2021-orange.svg)](https://www.rust-lang.org/)

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]#idgen
  - [Table of Contents]#table-of-contents
  - [Features]#features
  - [Installation]#installation
    - [Pre-built Binaries (Recommended)]#pre-built-binaries-recommended
    - [Build from Source]#build-from-source
  - [Quick Start]#quick-start
  - [Real-World Scenarios]#real-world-scenarios
    - [Manual Database Inserts \& Seeding](#manual-database-inserts--seeding)
    - [API Testing \& Development](#api-testing--development)
    - [Scripting \& Automation](#scripting--automation)
    - [Configuration \& Secrets](#configuration--secrets)
    - [Verification \& Debugging](#verification--debugging)
    - [Distributed Tracing]#distributed-tracing
    - [Mock Data Generation]#mock-data-generation
    - [Cloud Resource Naming]#cloud-resource-naming
    - [Debugging \& Inspection](#debugging--inspection)
  - [ID Types and Use Cases]#id-types-and-use-cases
    - [UUID (Universal Unique Identifier)]#uuid-universal-unique-identifier
      - [UUID v1 (Time-based)]#uuid-v1-time-based
      - [UUID v4 (Random)]#uuid-v4-random
      - [UUID v3/v5 (Name-based)]#uuid-v3v5-name-based
    - [MongoDB ObjectID]#mongodb-objectid
    - [NanoID]#nanoid
    - [CUID (Collision-resistant Unique Identifier)]#cuid-collision-resistant-unique-identifier
    - [ULID (Universally Unique Lexicographically Sortable Identifier)]#ulid-universally-unique-lexicographically-sortable-identifier
  - [Usage Guide]#usage-guide
    - [Command Options]#command-options
    - [Format Options]#format-options
    - [Examples]#examples
    - [Common UUID Namespaces]#common-uuid-namespaces
  - [Why idgen?]#why-idgen
  - [Contributing]#contributing
  - [License]#license

## 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


### Pre-built Binaries (Recommended)


Download the latest release for your platform from [GitHub Releases](https://github.com/maniartech/idgen/releases):

| Platform | Download |
|----------|----------|
| Linux (x64) | `idgen-linux-amd64` |
| macOS (x64) | `idgen-macos-amd64` |
| Windows (x64) | `idgen-windows-amd64.exe` |

```bash
# Linux/macOS: Make executable and move to PATH

chmod +x idgen-linux-amd64
sudo mv idgen-linux-amd64 /usr/local/bin/idgen

# Windows: Move to a directory in your PATH

```

### Build from Source


1. Install [Rust]https://www.rust-lang.org/learn/get-started if not already installed
2. Build from source:
   ```bash
   git clone https://github.com/maniartech/idgen.git

   cd idgen

   cargo build --release

   ```
3. Copy binary to your PATH:
   ```bash
   # Linux/macOS

   cp target/release/idgen /usr/local/bin/


   # Windows (PowerShell, adjust path as needed)

   Copy-Item target/release/idgen.exe -Destination "$env:USERPROFILE/AppData/Local/Microsoft/WindowsApps/"

   ```

## Quick Start


Generate a random UUID (v4):
```bash
idgen
```

Generate with banner:
```bash
idgen -b
```

Generate multiple IDs:
```bash
idgen -c 3
```

## 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.

```bash
# Generate 5 UUIDs for a seed file

idgen -c 5
```

### 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`.

```bash
# Use in a curl request

curl -X POST https://api.example.com/users \
  -H "X-Request-ID: $(idgen -f simple)" \
  -d '{"name": "John"}'
```

### Scripting & Automation


Use in CI/CD pipelines or shell scripts to generate unique filenames, deployment tags, or temporary resource identifiers.

```bash
# Create a unique temporary file

touch $(idgen -t nanoid -l 10 -p temp_ -s .log)
```

### Configuration & Secrets


Generate unique strings for configuration files, such as `JWT_SECRET`, `API_KEY`, or session secrets during project setup.

```bash
# Generate a strong, random secret

idgen -t nanoid -l 64
```

### Verification & Debugging


Verify the output of deterministic IDs (like UUID v5) to ensure your application logic matches the standard.

```bash
# Verify UUID v5 generation

idgen -t uuid5 --namespace URL --name "https://example.com"
```

### Distributed Tracing


Generate a unique trace ID to manually tag a request flow across microservices when debugging.

```bash
# Generate a trace ID (UUID v4)

idgen -f simple
```

### Mock Data Generation


Generate IDs for JSON mock files used in frontend development.

```bash
# Generate 10 NanoIDs for a mock user list

idgen -t nanoid -c 10

# Generate mock email addresses

idgen -t nanoid -l 8 -s @example.com -c 5
```

### Cloud Resource Naming


Generate unique tags for cloud resources (AWS/Azure/GCP) during manual provisioning or Terraform/Ansible runs.

```bash
# Generate a unique suffix for an S3 bucket

idgen -t nanoid -l 8 -p my-bucket- | tr '[:upper:]' '[:lower:]'
```

### Debugging & Inspection


Analyze unknown IDs found in logs or databases to determine their type, version, and creation timestamp (if available).

```bash
# Inspect an ID to see what it is

idgen inspect 01ARZ3NDEKTSV4RRFFQ69G5FAV

# Check if an ID is valid with JSON output

idgen inspect 550e8400-e29b-44d4-a716-446655440000 --json
```

## 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

          Possible values:
          - uuid1:    UUID version 1 (time-based)
          - uuid3:    UUID version 3 (MD5 hash-based, requires --namespace and --name)
          - uuid4:    UUID version 4 (random)
          - uuid5:    UUID version 5 (SHA1 hash-based, requires --namespace and --name)
          - nanoid:   NanoID (URL-safe, configurable length)
          - cuid1:    CUID version 1
          - cuid2:    CUID version 2
          - ulid:     ULID (Universally Unique Lexicographically Sortable Identifier)
          - objectid: MongoDB ObjectID

          [default: uuid4]

  -f, --format <FORMAT>
          Output format for UUIDs

          Possible values:
          - hyphenated: Standard hyphenated format (e.g., 550e8400-e29b-44d4-a716-446655440000)
          - simple:     Simple format without hyphens (e.g., 550e8400e29b44d4a716446655440000)
          - urn:        URN format (e.g., urn:uuid:550e8400-e29b-44d4-a716-446655440000)

          [default: hyphenated]

  -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 a summary with '-h')

          Name string for UUID v3/v5

      --json
          Output as JSON

  -b, --banner
          Show banner

  -h, --help
          Print help (see a summary with '-h')


      --json
          Output as JSON

  -b, --banner
          Show banner

  -h, --help
          Print help (see a summary with '-h')

      --json
          Output as JSON

  -b, --banner
          Show banner

  -h, --help
          Print help (see a summary with '-h')


  -b, --banner
          Show banner

  -h, --help
          Print help (see a summary with '-h')

  -b, --banner
          Show banner

  -h, --help
          Print help (see a summary with '-h')

          Show banner

  -h, --help
          Print help (see a summary with '-h')

  -h, --help
          Print help (see a summary with '-h')

          Print help (see a summary with '-h')


  -V, --version
          Print version
  -V, --version
          Print 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


```bash
# Generate IDs (default: UUID v4)

idgen                              # Random UUID v4
idgen -t uuid1                     # Time-based UUID v1
idgen -t uuid5 --namespace DNS --name example.com  # Name-based UUID v5

# ID Types

idgen -t nanoid                    # NanoID (21 chars)
idgen -t nanoid -l 10              # NanoID with custom length
idgen -t cuid1                     # CUID v1
idgen -t cuid2                     # CUID v2
idgen -t ulid                      # ULID
idgen -t objectid                  # MongoDB ObjectID

# UUID Formats

idgen -f simple                    # No hyphens: 550e8400e29b44d4a716446655440000
idgen -f urn                       # URN format: urn:uuid:550e8400-e29b-...

# Multiple IDs

idgen -c 5                         # Generate 5 UUIDs
idgen -t ulid -c 3                 # Generate 3 ULIDs

# Prefix and Suffix

idgen -p 'test-'                   # Add prefix
idgen -s '.log'                    # Add suffix
idgen -p 'user_' -s '_v1' -c 3     # Both prefix and suffix

# JSON Output

idgen --json                       # Single ID as JSON
idgen --json -c 3                  # Multiple IDs as JSON array

# Inspect IDs

idgen inspect 550e8400-e29b-44d4-a716-446655440000
idgen inspect 01ARZ3NDEKTSV4RRFFQ69G5FAV

# Shell Completions

idgen completions bash > ~/.bash_completion.d/idgen
idgen completions zsh > ~/.zsh/completions/_idgen
idgen completions fish > ~/.config/fish/completions/idgen.fish
idgen completions powershell >> $PROFILE

# Man Page

idgen manpage > /usr/local/share/man/man1/idgen.1
```

### 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®](https://www.maniartech.com/)