jwt is a command line (CLI) tool to encode or decode JSON Web Tokens (JWT).
jwt decode tokens/hs256.token{
"header": {
"alg": "HS256",
"typ": "JWT"
},
"payload": {
"sub": "1234567890",
"name": "John Doe",
"iat": 1516239022
},
"signature": "SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"
}jwt decode --string eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c{
"header": {
"alg": "HS256",
"typ": "JWT"
},
"payload": {
"sub": "1234567890",
"name": "John Doe",
"iat": 1516239022
},
"signature": "SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"
}cat tokens/hs256.token | jwt decode{
"header": {
"alg": "HS256",
"typ": "JWT"
},
"payload": {
"sub": "1234567890",
"name": "John Doe",
"iat": 1516239022
},
"signature": "SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"
}jwt encode --key secret_key tokens/hs256.json
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.-31VfEDt_2aatZ0NIjznd27ruqyeMC4zus1J3hjZltsexport JWT_JSON='{"header":{"alg":"HS256","typ":"JWT"},"payload":{"sub":"1234567890","name":"John Doe","iat":1516239022},"signature":"SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"}'
jwt encode --key secret_key --string "$JWT_JSON"
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.-31VfEDt_2aatZ0NIjznd27ruqyeMC4zus1J3hjZltsjwt encode --key secret_key tokens/hs256.json | jwt decode{
"header": {
"alg": "HS256",
"typ": "JWT"
},
"payload": {
"sub": "1234567890",
"name": "John Doe",
"iat": "2018-01-17T19:30:22-06:00"
},
"signature": "-31VfEDt_2aatZ0NIjznd27ruqyeMC4zus1J3hjZlts"
}jwt --help JWT Command Line 0.11.0
Copyright (c) 2021-2024 - Andre Burgaud
MIT License
Description:
Manipulate (encode, or decode) JSON Web Tokens (JWT).
Usage:
jwt [OPTIONS]
jwt [COMMAND] [OPTIONS] [ARGS]
Options:
-h, --help Print help
-v, --version Print version info
Commands:
decode Decode a Base64 encoded JWT into a valid JSON string
encode Encode a JSON file or string into a Base64 encoded JWT
jwt [COMMAND] --help for more information on a specific command.
jwt is written in Nim, which needs to be installed to build jwt.
To build a debug version of jwt, execute the following command:
nimble buildThe executable will be available at the root of the project. For a simple test, on Linux or Mac OS, you can run:
./jwt decode tokens/hs256.tokenTo build a debug version of jwt, execute the following command:
nimble releaseThe executable will be available in bin/release.
To execute the unit tests, execute the following command:
nimble testto build a windows distribution on Linux:
nimble dist_xc_win64The nimbe task dist_xc_win64 will create a 64-bit release version and a zip package under dist.
jwt is release under the MIT License