@lxgicstudios/jwt-gen
v1.0.0
Published
Generate and decode JWT tokens from the command line. Support for HS256 and RS256 with custom claims and expiry. Zero dependencies.
Downloads
8
Maintainers
Readme
jwt-gen
Generate and decode JWT tokens from the command line. Supports HS256 and RS256 signing, custom claims, and configurable expiry. Zero external dependencies.
Install
npm install -g @lxgicstudios/jwt-genOr run directly:
npx @lxgicstudios/jwt-gen --secret "my-key" --sub "user123"Features
- Generate JWT tokens with HS256 or RS256 signing
- Decode and inspect any JWT token
- Verify token signatures
- Custom claims with
--claim key=value - Configurable expiry (30m, 1h, 7d, 365d)
- Standard claims support (iss, sub, aud)
- JSON output for scripting
- Zero external dependencies (uses Node's built-in crypto)
Usage
Generate a token
jwt-gen --secret "my-secret-key" --sub "user123" --exp 24hAdd custom claims
jwt-gen -s "secret" --claim "role=admin" --claim "tier=pro" --claim "active=true"Generate with RS256
jwt-gen --algo RS256 --key private.pem --sub "my-service"Decode a token
jwt-gen --decode "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."Decode and verify
jwt-gen --decode "eyJhbG..." --secret "my-secret" --verifyOptions
| Option | Alias | Default | Description |
|--------|-------|---------|-------------|
| --help | -h | | Show help message |
| --json | | | Output as JSON |
| --secret | -s | | HMAC secret key (for HS256) |
| --key | -k | | Private key file path (for RS256) |
| --pub | | | Public key file path (for verification) |
| --algo | -a | HS256 | Algorithm: HS256 or RS256 |
| --exp | -e | 1h | Expiry duration (30m, 1h, 7d, etc.) |
| --iss | | | Issuer claim |
| --sub | | | Subject claim |
| --aud | | | Audience claim |
| --claim | | | Custom claim as key=value (repeatable) |
| --decode | -d | | Decode a JWT token |
| --verify | | | Verify signature when decoding |
Duration Formats
| Format | Meaning |
|--------|---------|
| 30s | 30 seconds |
| 30m | 30 minutes |
| 1h | 1 hour |
| 24h | 24 hours |
| 7d | 7 days |
| 52w | 52 weeks |
License
MIT - LXGIC Studios
