JWT generator

Build a JSON Web Token: edit the payload, pick HS256, HS384 or HS512 and a secret, and the signed token appears straight away. Signing happens in your browser with Web Crypto.

runs in your browser · nothing uploaded

loading tool…

How to use it

  1. Edit the payload JSON. Use the buttons to set iat to now or exp to one hour or one day from now.
  2. Choose the algorithm. HS256 is the most widely supported.
  3. Paste your secret, or press "random secret" for a new one of the right length.
  4. Copy the token. Paste it into the JWT decoder to read it back, or into your API client to test.

What gets signed

A JWT is three Base64url parts joined by dots: a header such as {"alg":"HS256","typ":"JWT"}, the payload, and a signature. The signature is an HMAC of "header.payload" made with the secret. Anyone can read the payload; only someone with the secret can make a valid signature.

iat (issued at) and exp (expiry) are Unix timestamps in seconds, as RFC 7519 defines them. Most libraries reject a token once exp has passed.

How long should the secret be?

RFC 7518 says an HMAC key must be at least as long as the hash: 256 bits for HS256, 384 for HS384 and 512 for HS512. Many libraries refuse shorter keys, and a short human-made secret can be brute-forced from a single token. The page warns you when the secret is too short.

Sign one in Node.js

With only node:crypto: Base64url-encode the header and payload, then createHmac('sha256', secret).update(header + '.' + payload).digest('base64url') is the signature. Our script in examples/generators does exactly this and verifies the result with timingSafeEqual.

Questions

Is my secret sent anywhere?

No. Signing uses your browser's Web Crypto API. Even so, use test secrets here rather than your production signing key.

Can I make RS256 or ES256 tokens?

Not yet. Those need a private key pair; this page covers the HMAC algorithms, which are the common choice for tokens a single service issues and checks.

Is the payload encrypted?

No. It is only encoded, so anyone with the token can read it. Never put passwords or secrets in a JWT payload.

// go deeper
JWTs explained: decode one and know what to trust
read the guide →