03 / API & Auth / jwt-generator
JWT Generator
Create signed test JSON Web Tokens (HS256/384/512).
How to use
- 01Pick a signing algorithm: HS256, HS384 or HS512.
- 02Enter a signing secret in the masked Secret field. It is used locally and never stored.
- 03Edit the JSON payload, which must be a JSON object, or fill the optional claim helpers for iss, sub, aud, exp, iat, nbf and jti. Use iat = now and exp = +1h to fill the time claims.
- 04Press Generate JWT (or Ctrl/Cmd + Enter). The token is masked until you tick Show token.
- 05Press Copy JWT, or Decode generated token to open it in the JWT Decoder.
What is this tool?
This generator signs test JSON Web Tokens with HMAC (HS256, HS384 or HS512) using your browser's Web Crypto API. You supply a JSON payload and a secret, optionally add registered claims through helper fields, and get a compact header.payload.signature token. It is designed for local development and API testing, not as a production token service, and the secret only lives in memory while the page is open.
How HS256 JWT signing works
The generator builds the header {"alg":"HS256","typ":"JWT"} (with HS384 or HS512 if you choose those), Base64URL-encodes it and the payload, and joins them with a period. That string is the signing input. It is then signed with HMAC using SHA-256, SHA-384 or SHA-512 and your secret, and the Base64URL-encoded result becomes the third section.
With the default payload, the first two sections are eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9 and eyJzdWIiOiIxMjM0NSIsIm5hbWUiOiJUZXN0IFVzZXIiLCJyb2xlIjoidXNlciJ9. Any server that knows the same secret can recompute the signature and accept the token.
The secret is used as its UTF-8 text bytes. If your backend treats its secret as Base64 or hex and decodes it before verifying, the signatures will not match, so pass the same raw string your server uses. For HS256, RFC 7518 recommends a key of at least 256 bits, such as 32 random bytes.
Setting exp, iat and nbf for test tokens
The claim helpers write registered claims into the payload and overwrite any key of the same name you typed in the JSON. Empty fields are skipped. exp, iat and nbf must be Unix timestamps in seconds; a value that is not a number is silently left out. iat = now fills the current time, and exp = +1h fills the current time plus 3,600 seconds.
This makes negative tests easy. Set exp to a time in the past to check that your API returns 401 for an expired token, set nbf in the future to test not-yet-valid handling, or change aud to confirm the API rejects tokens issued for a different audience. Generate one token per role claim to exercise role-based access control.
HS256 vs RS256: when a shared secret is enough
HMAC algorithms like HS256 use one shared secret to both sign and verify, so every service that checks the token can also mint new ones. That is fine for a single API and for test fixtures, which is what this tool is for. Identity providers such as Auth0, Okta, Azure AD and Cognito usually sign with RS256 or ES256 instead: a private key signs and services verify with a public key, often published as a JWKS endpoint.
If your API only accepts RS256 tokens, an HS256 token from this generator will be rejected. Point the API at a test configuration that accepts a shared HMAC secret, or obtain a real token from your provider's test tenant.
Common use cases
- Creating fixture tokens for automated API tests
- Reproducing an expired-token scenario with a custom exp claim
- Testing role-based access control with different payloads
- Checking that an API rejects a token signed with the wrong secret
- Learning how JWT structure and claims work
FAQ
Is this JWT generator safe for production?
No. Use it for development and testing tokens only. Production tokens should be issued by your auth server, whose secret never leaves it.
Where does signing happen?
In your browser, via the Web Crypto API.
Which algorithms are supported?
HMAC-based HS256, HS384 and HS512. RSA and ECDSA algorithms such as RS256 and ES256 are not supported.
Is my secret stored?
No. It only exists in memory while the page is open.
Why does my server reject the generated token?
The most common causes are a different secret (including a Base64-encoded secret on the server), an algorithm mismatch, or exp, nbf, iss or aud values your server rejects.
How do I make a token that expires in one hour?
Press exp = +1h to fill the expiration with the current time plus 3,600 seconds, then press Generate JWT.