Decode
Generate
JWT Token
Verification Key/Secret Optional - leave empty for decode only
Header
-
Payload
-
Signature
-

About JSON Web Tokens (JWT)

JSON Web Tokens (JWT), defined in RFC 7519, are compact, URL-safe tokens used to securely transmit claims between two parties. They are widely used for authentication and authorization in web applications and APIs.

JWT Structure

A JWT consists of three Base64URL-encoded parts separated by dots: header.payload.signature

  • Header - declares the token type (JWT) and the signing algorithm (e.g. HS256, RS256).
  • Payload - contains the claims (data), such as user identity and expiration time.
  • Signature - verifies the token hasn't been tampered with, created by signing the header and payload with a secret or private key.

Common JWT Claims

Claim Name Description
subSubjectIdentifies the principal (usually a user ID)
issIssuerWho issued the token
audAudienceIntended recipient(s) of the token
expExpirationUnix timestamp after which the token is invalid
iatIssued AtUnix timestamp when the token was created
nbfNot BeforeUnix timestamp before which the token is not valid
jtiJWT IDUnique identifier to prevent token reuse

Signing Algorithms Compared

Algorithm Type Best For
HS256Symmetric (HMAC-SHA256)Simple setups where signer and verifier share a secret
RS256Asymmetric (RSA-SHA256)Distributed systems where verifiers shouldn't have signing access
ES256Asymmetric (ECDSA-P256)Like RS256 but with smaller keys and faster signing

Security Best Practices

  • Always verify the signature before trusting any claims in the payload.
  • Don't store sensitive data in the payload - JWTs are encoded, not encrypted. Anyone can read the contents.
  • Use short expiry times (exp) and refresh tokens for long-lived sessions.
  • Reject the "none" algorithm in your verification logic to prevent signature bypass attacks.
  • Validate the expected algorithm on the server side rather than trusting the token's header.