JWT Generator

Create JSON Web Tokens with custom headers, payloads, and secrets. Signs tokens using HS256 (HMAC SHA-256) via the Web Crypto API. 100% client side - nothing leaves your browser.

Header: -

Payload: -

Signature: -

About JWT Generation

JSON Web Tokens (JWT) are a compact, URL safe way to represent claims between two parties. This tool generates signed JWTs using the HMAC SHA-256 algorithm, which is the most commonly used symmetric signing method.

How It Works

  • The header and payload are Base64url-encoded
  • A signature is created using HMAC-SHA256(base64url(header) + "." + base64url(payload), secret)
  • The final token is header.payload.signature
  • All signing happens client side via the Web Crypto API

Common Payload Claims

  • sub - Subject (user ID)
  • iat - Issued At (Unix timestamp)
  • exp - Expiration Time (Unix timestamp)
  • iss - Issuer
  • aud - Audience

Related Tools

Generating JWTs (Carefully) for Local Testing

JSON Web Tokens are the dominant stateless auth format on the modern web — every OAuth/OIDC flow, every Auth0 / Cognito / Firebase session, every API gateway. Generating a JWT locally is useful for testing handlers, mocking auth in dev environments, and reproducing edge cases you've seen in production. It is not safe to use locally generated JWTs for anything in production.

JWT structure

Three base64url-encoded parts separated by dots: header.payload.signature.

  • Header. {"alg":"HS256","typ":"JWT"} — the signing algorithm.
  • Payload. The "claims": sub (subject), iat (issued at), exp (expiry), iss (issuer), aud (audience), plus your own.
  • Signature. HMAC-SHA256(secret, header.payload) for HS256, or an RSA/ECDSA signature for RS256/ES256.

Picking an algorithm

  • HS256 (HMAC). Symmetric, single shared secret. Fast and simple. Good for monoliths or services where the issuer and verifier are the same code.
  • RS256 (RSA). Asymmetric. The issuer signs with a private key; verifiers use the public key. Right for any system where the verifier shouldn't be able to mint tokens (microservices, third-party APIs).
  • ES256 (ECDSA P-256). Same as RS256 but with smaller keys and signatures. Recommended for new systems.
  • none. Means no signature. Never accept this in production — many "JWT bypass" CVEs come from libraries that allow it.

Standard claims to set correctly

  • exp — expiry, Unix epoch seconds. Mandatory in any real system.
  • iat — issued at. Useful for revocation policies.
  • nbf — not before. Token is invalid until this time.
  • iss — issuer. Hardcode and verify exactly.
  • aud — audience. Verify your service is the intended audience.
  • sub — subject (typically user ID).
  • jti — unique JWT ID. Useful for one-time-use tokens.

Common pitfalls

  • Long-lived tokens with no revocation. Once issued, JWTs are valid until they expire. Use short expiries (5–15 minutes) plus refresh tokens for sessions.
  • Storing in localStorage. XSS-readable. Prefer HttpOnly cookies with SameSite=Strict.
  • Storing sensitive data in payload. The payload is base64-encoded, not encrypted. Anyone can read it.
  • Verifying without checking alg. Some libraries trust the alg in the header, allowing an attacker to switch from RS256 to HS256 and sign with the public key as a secret.
  • Not validating iss and aud. Without these checks, a JWT minted for service A can be replayed against service B.

This generator produces test JWTs in your browser — never use the output in production. For deeper SSO context, see SAML vs OIDC vs OAuth2 in 2026.

Frequently Asked Questions

Should I use HS256 or RS256?

For a single-codebase monolith, HS256 is simpler. For any system with separate issuer and verifier services, RS256 (or ES256). Never use HS256 across trust boundaries.

How long should a JWT live?

Access tokens: 5–15 minutes. Refresh tokens: hours to days. ID tokens: minutes. Long-lived (24+ hour) access tokens are a security smell.

Is the JWT payload encrypted?

No, only base64url-encoded. Anyone with the token can read the claims. Use JWE (encrypted JWT) if you need confidentiality.

Why is the alg=none vulnerability still mentioned?

Some libraries default to accepting unsigned tokens. Always pin your accepted algorithms explicitly.