JWT Encoder & Verifier

Sign a JWT with HS256, HS384 or HS512, or verify a token against a secret or public key.

About JWT Encoder & Verifier

A JWT encoder that signs a header and payload with HS256, HS384 or HS512, and verifies the signature of a token against a secret or public key.

How to use

  1. In Encode, pick the algorithm, edit the header and payload JSON, and type the secret. The signed token appears as soon as there is a secret.
  2. Tick Secret is Base64-encoded when your key is stored as Base64 rather than typed as text.
  3. In Verify, paste a token and the secret it was signed with. For RS256 or ES256 tokens, paste the public key as PEM (-----BEGIN PUBLIC KEY-----) or as a JWK.
  4. The result says whether the signature matches, and the decoded header and payload are shown beside it.

What it does

  • Signing: the header and payload are parsed, written back as compact JSON with the keys in the order you typed them, Base64URL-encoded without padding, and joined with a dot. That string is signed with HMAC-SHA-256, 384 or 512 through WebCrypto. The alg in the header decides which; the algorithm switch only rewrites that field.
  • Verifying: the algorithm is read from the token header. HS256, HS384 and HS512 are checked against the secret; RS256 (RSASSA-PKCS1-v1_5 with SHA-256) and ES256 (ECDSA on P-256 with SHA-256) are checked against the public key.
  • After a valid signature the exp and nbf claims are compared with your device's clock, and an expired or not yet valid token is reported.
  • A secret shorter than the hash output (32, 48 or 64 bytes) gets a warning, because RFC 7518 requires at least that much and a short secret can be guessed offline from a single token.

What it does not do:

  • It signs with HMAC only. It does not create RS256 or ES256 tokens, and no private key is ever asked for.
  • It does not verify RS384, RS512, PS256, ES384, ES512 or EdDSA, and it does not handle encrypted tokens (JWE).
  • It refuses tokens with alg set to none, and it does not check iss, aud or any other claim.
  • A certificate or a PKCS#1 BEGIN RSA PUBLIC KEY block is not accepted as a key. Extract the public key with openssl x509 -pubkey -noout first.

Example

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

→ eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c

Privacy

Signing and verification use the browser's WebCrypto API on this page. The secret, the keys and the tokens are not uploaded, no request is made, and nothing is stored.

Frequently asked questions

How do I create a JWT with HS256?
Write a header of {"alg":"HS256","typ":"JWT"} and a payload of claims, Base64URL-encode each, join them with a dot, and sign that string with HMAC-SHA-256 using your secret. The token is the two encoded parts and the encoded signature joined by dots, which is what this tool produces as you type.
How do I verify a JWT signature?
Recompute the signature over the first two parts of the token with the same algorithm and key, and compare it with the third part. For HS256 the key is the shared secret; for RS256 or ES256 it is the public key of the issuer. Switch this tool to Verify, paste both, and it reports whether they match.
What is the difference between HS256 and RS256?
HS256 is symmetric: one secret both signs and verifies, so every service that can check a token can also forge one. RS256 is asymmetric: a private key signs and a public key verifies, so the public key can be shared freely. Use HS256 inside one system and RS256 or ES256 when other parties verify your tokens.
Is the payload of a JWT encrypted?
No. A signed JWT is only Base64URL-encoded, so anyone who holds the token can read the header and payload. The signature stops the contents being changed, not being read. Do not put passwords or other secrets in a JWT.