JWT Encoder and Signer
Build, sign and verify JWTs with HMAC, RSA or ECDSA keys.
Use via API
Sign a JWT (HS256/384/512 with a shared secret, or RS/PS/ES with a PEM private key), or verify a token's signature and exp/nbf/iat claims. Send JSON, get JSON back.
POST https://pithlab.com/api/v1/tools/jwt-encoder
curl https://pithlab.com/api/v1/tools/jwt-encoder \
-H "Authorization: Bearer $PITHLAB_KEY" \
-H "Content-Type: application/json" \
-d '{"mode":"sign","alg":"HS256","key":"a-string-secret-at-least-256-bits-long","payload":"{\"sub\":\"1234567890\",\"name\":\"Ada\",\"iat\":1700000000}"}'About the JWT Encoder
Create and sign JSON Web Tokens with HS256, RS256, PS256 or ES256, add iat and exp in one click, and verify a token's signature and expiry. Runs in your browser.
How to use the JWT Encoder
- Choose Sign to create a token, or Verify to check one.
- Edit the header and payload JSON. Use the buttons to set iat, nbf or exp from the current time.
- Pick an algorithm. For HS256, HS384 and HS512 enter a shared secret as text or Base64; for RS, PS and ES algorithms paste a PKCS#8 private key in PEM format.
- Press Sign token and copy the JWT.
- To verify, paste the token and the secret or public key (SPKI PEM). The tool checks the signature, exp and nbf with a clock skew allowance, and rejects alg none.
Examples
Input
Header: {"alg":"HS256","typ":"JWT"}
Payload: {"sub":"1234567890","name":"John Doe","iat":1516239022}
Secret: your-256-bit-secretOutput
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c
Input
Token: eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFtcGxlLmNvbS9pc19yb290Ijp0cnVlfQ.dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk Secret (Base64): AyM1SysPpbyDfgZld3umj1qzKObwVMkoqQ-EstJQLr_T-1qS0gZH75aKtMN3Yj0iPS4hcgUuTwjAzZr1Z9CAow
Output
Token rejected: signature valid, exp failed
Input
Token: eyJhbGciOiJub25lIn0.eyJzdWIiOiJhZG1pbiJ9.
Output
Rejected: alg is "none", which means the token is unsigned and anyone could have written it.
Frequently asked questions
Which algorithm should I use?
Use HS256 when the same service creates and checks tokens and can keep a secret. Use RS256, PS256 or ES256 when other services must verify tokens without being able to create them, because they only need the public key.
What key format does it need?
For RS, PS and ES algorithms, a PKCS#8 private key (-----BEGIN PRIVATE KEY-----) to sign and an SPKI public key (-----BEGIN PUBLIC KEY-----) to verify. Older RSA PRIVATE KEY or EC PRIVATE KEY files can be converted with openssl pkcs8 -topk8 -nocrypt.
Why does verification reject alg none?
A token with alg none has no signature, so anyone can write one. Accepting it is a classic JWT vulnerability. This tool also refuses to use a PEM public key as an HMAC secret, which blocks the related algorithm confusion attack.
What is clock skew?
Servers' clocks are rarely in perfect sync. The skew allowance, 60 seconds by default, lets a token be accepted slightly after exp or slightly before nbf.
Is it safe to paste a real key here?
Signing and verifying run in your browser with the Web Crypto API and nothing is uploaded. Even so, avoid pasting production private keys into any web page; use test keys where you can.