A JWT CLI written in Go.
Also includes:
- A single html file web app for quickly decoding JWT tokens: available online at jwt.etelej.com
- You can grab the html file at ./webapp - uses petite-vue
Download executable for your OS from Releases
- Works on most platforms: Windows, iOS, Linux etc
Alternative installation (with Go):
go get -u github.com/peteretelej/jwt
Decode token and print details in human readable format
- Add headers to sections
- Parse timestamps
- Provide human readable durations eg ( expires in 1yr )
./jwt TOKEN
Verify if token is signed by a secret
./jwt --secret SECRET TOKEN
Generate JWT token
./jwt --secret demopass --sign '{"user": "John Doe"}'
Specify an expiry period for the generated token
./jwt --secret demopass --exp 1y --sign '{"user": "John Doe"}'
- Supports durations (eg year to second) such as
yr, mo, w, d, h,m,s
- examples:
--exp 6mo
(6 months),--exp 2w
(2 weeks)
If you don't want to paste secret as plain text in command line:
- do not specify the
--secret
argument, it will prompt pasting or typing secret (does not print the secret)
./jwt --sign '{"user": "Jane Doe"}'
Please enter a secret to sign the JWT (and press Enter)
Usage Examples
Generating a signed JWT token
./jwt --sign '{"name": "John Doe"}' --secret demopass --exp 2w
Decode JWT token
./jwt eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2Mjc3NTkyNzUsIm5hbWUiOiJKb2huIERvZSJ9.SF2XbD6QpxxcV95Oa_AC1oXysfWcF9gmyMEaNAHagP0
Verifying a token's signing key
./jwt --secret demopass eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2Mjc3NTkyNzUsIm5hbWUiOiJKb2huIERvZSJ9.SF2XbD6QpxxcV95Oa_AC1oXysfWcF9gmyMEaNAHagP0
Decoding a token with multiple standard claims
./jwt eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNjIxMjY5Mjg2LCJleHAiOjE2Mzk3NTg4ODYsIm5iZiI6MTYyMzk0NzY4Nn0.GR5pGSiJZk3Ls0A429K3HIZfsmQqGnyIhPusDT5F5BU
License: MIT