Skip to content
PithLab

↑↓ to move · Enter to open · Esc to close

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}"}'

Fields and responseOpenAPI documentGet an API key

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

  1. Choose Sign to create a token, or Verify to check one.
  2. Edit the header and payload JSON. Use the buttons to set iat, nbf or exp from the current time.
  3. 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.
  4. Press Sign token and copy the JWT.
  5. 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

Sign the jwt.io HS256 example

Input

Header: {"alg":"HS256","typ":"JWT"}
Payload: {"sub":"1234567890","name":"John Doe","iat":1516239022}
Secret: your-256-bit-secret

Output

eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c
Verify the RFC 7515 HS256 example (expired in 2011)

Input

Token: eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFtcGxlLmNvbS9pc19yb290Ijp0cnVlfQ.dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk
Secret (Base64): AyM1SysPpbyDfgZld3umj1qzKObwVMkoqQ-EstJQLr_T-1qS0gZH75aKtMN3Yj0iPS4hcgUuTwjAzZr1Z9CAow

Output

Token rejected: signature valid, exp failed
An unsigned token is rejected

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.

Guides that use this tool

  • How to read a JWT without leaking it

    A JSON Web Token is just three Base64url chunks. Here's how to read the header and claims, what to check, and why you should never paste one into a random site.