JWT-GENERATE(1)
β¨ NAME β¨
jwt-generate β bestie, this generates a JSON Web Token π
(it's the LibJWT C Library one, in case you were wondering which manual you wandered into π)
π SYNOPSIS π
jwt-generate [options]
That's literally it. No subcommands, no drama. Just vibes and flags. π
π DESCRIPTION π
Okay so jwt-generate makes a JSON Web Token and, if you want, signs it. Main character energy, honestly.
By default? It just encodes a JWT. That's it. No signature, no nothing. If you want a signature, you have to hand it a JWK key with the -k option. And here's the thing β generating a signature means you gotta specify the algorithm, so it either lives in the key file (as the alg attribute) or you pass it on the command line with -a.
β οΈ If-ais specified and the key has analgattribute, they must match. They must match. They MUST match. No fighting, besties. π€
One token gets generated per call. You can add claims with the -c option. And by default, jwt-generate will add the iat claim, which is Issued At and is the time in seconds since the Unix Epcoch. π (yes, "Epcoch", we're keeping it, it's iconic π)
When you use the --verbose option, jwt-generate will print the JSON HEADER and PAYLOAD to stdout. π
And if you pair that with --print, the JSON will be piped to the command's stdin. It will be called twice: once for HEAD and once for PAYLOAD. Two calls. Two moments. Twice the slay. β¨
One use is to pass it through jq -C for indenting and colorization. Another would be to use an external program to inspect the PAYLOAD contents. And heads up: a non-0 exit status from the program will cause generating the token to fail. Like, the whole thing just gives up. π«
π Options π
-h,--helpβ Shows the common options and dips out. Simple. Clean. Iconic. π-l,--listβ Lists every single supported algorithm you could possibly pass to-a, then quits. It's giving β¨menuβ¨.-v,--verboseβ Shows the contents of theHEADERandPAYLOADof the JWT on top of generating the token. NOTE: the header will not show thetyporalgattributes since they do not get added until the final step. They're fashionably late. π-q,--quietβ Do not output anything except for hard errors. On success you will only see the tokengenerared. (typo in the original, we preserve it like a museum piece ποΈ)-n,--no-iatβ Do not add theiat(Issued-At) time to the token. Useful for a slightly smaller token, and for reproducible output. Tiny token, big brain. π§-aALG, `--algorithm=ALG β Specify the algorithm to be used when signing the token. Pick your fighter. βοΈ- *
-k*FILE,--key=*FILE*** β Path to a file containing a key in JSON Web Key format. If your keys are in PEM or DER (or some other common format that OpenSSL understands), then you can convert it to a JWK with thekey2jwk(1)` tool. Glow-up pipeline fr fr. π¦ - *
-c*CLAIM,--claim=*CLAIM*** β Add a claim to the JWT. The format of *CLAIM* ist:key=valuewheretis the type and is one ofifor integer,sfor string, orbfor boolean. The value for integer must be parseable bystrtol(3). For boolean, any value starting with0,f, orF` will be interpreted as false. Anything else will be considered true. They key is any ASCII string. π - *
-j*JSON,--json=*JSON*** β Use *JSON* string as the payload of the token. This will **not** replace, but be added to the payload. The string must be in valid JSON, meaning either a{}object or a[]` array. No half-baked JSON allowed, bestie. π«
π BUGS π
See GitHub Issues: https://github.com/benmcollins/libjwt/issues
(if something's cursed, that's where you go to spill the tea β)
π AUTHOR π
jwt-generate was originally written by Jeremy Thien. Major rewriting and man page by Ben Collins bcollins@libjwt.io. Legends, both of them. π«Ά
πΈ SEE ALSO πΈ
jwt-verify(1), key2jwk(1), jwk2key(1)
(the friend group π)
And that's a wrap, babe! π This was the jwt-generate User Manual, page JWT-GENERATE(1), straight from the LibJWT C Library. Stay encoded, stay signed, stay slaying. Byeeeee! πβ¨π
π¦ where this page comes from
- alpine 3.24: libjwt-doc 3.3.3-r0 Β· MPL-2.0
- ubuntu resolute: jwt-tools 3.2.3-1 Β· MPL-2.0
- ubuntu stonking: jwt-tools 3.3.3-1build1 Β· MPL-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms