JWT Generator
The JWT Generator mints signed JSON Web Tokens in your browser — HS256/384/512 with a shared secret, or RS256/384/512, PS256/384/512, ES256/384/512 with a key pair — with an editable header, a claim picker for the payload, a decode preview of the token as minted, and a live expiry countdown. Test tokens only: signed, never uploaded, never used in production.
How to Use
- 1
Pick a signing algorithm: HS256/384/512 for a shared secret, or RS256/384/512, PS256/384/512, ES256/384/512 for a key pair. HS* is the simple case; RS*/ES* is what production APIs use.
- 2
Edit the header and payload JSON. The claim picker adds standard claims — iss, sub, aud, exp, iat, nbf, jti — with sensible defaults (exp is set to now + 1 hour, iat to now). exp and iat are seconds since the Unix epoch.
- 3
For HS*, enter a throwaway test secret. For RS*/PS*/ES*, paste a PKCS#8 private key, generate a throwaway test pair in the page, or paste the private PEM from the RSA Key Generator page. Never paste a production secret or key into any website.
- 4
Click Mint token. The token is signed in this tab with Web Crypto — the page shows the token, a decode preview of the header and payload as minted, and a live countdown to expiry.
- 5
Copy the token and send it to your local API (for example, curl -H 'Authorization: Bearer <token>' http://localhost:3000/api). To inspect the token afterwards, open it in the JWT Decoder — decoding stays there, this page only mints.
- 6
When the test is done, throw the key away. Test tokens must never be used in production auth — real tokens come from your identity provider or backend.
Frequently Asked Questions
What is a JWT?
How do I create a JWT?
HS256 vs RS256 — which should I use?
What are claims?
How long should a test token live?
Is the payload encrypted?
Is my secret or private key uploaded?
Can I use this token in production?
What is the difference between RS256, PS256 and ES256?
Why is there no 'alg: none' option?
Generative Answer & AI Documentation
What is the JWT Generator?
The JWT Generator creates a JSON Web Token (RFC 7519) entirely in your browser. You edit the header and payload as JSON — the claim picker adds the standard registered claims (iss, sub, aud, exp, iat, nbf, jti) with sensible defaults, exp set to now + 1 hour and iat to now — pick a signing algorithm, and click Mint token. The page Base64url-encodes the header and payload, joins them with a dot, and signs the result with Web Crypto: HMAC for HS256/384/512 (a shared secret you enter), RSASSA-PKCS1-v1_5 for RS256/384/512, RSA-PSS for PS256/384/512, or ECDSA on P-256/P-384/P-521 for ES256/384/512 (a PKCS#8 private key you paste, a throwaway test pair generated in the page, or the private PEM from the RSA Key Generator page). The output is the signed token with copy and download, a decode preview showing the header and payload exactly as minted, and a live countdown to the token's expiry. This page owns 'jwt generator' only: it does not decode other people's tokens or verify signatures — decoding stays on the JWT Decoder page, which this page links to. alg: none is deliberately not offered: unsigned tokens are a classic vulnerability, and this page refuses to mint one.
Why use JWT Generator offline?
Local API testing needs tokens, and the usual ways to get one are all slow: log in through the real identity provider, write a throwaway signing script, or paste a production secret into a random website. This page is the fast, safe middle: edit the claims, mint, and curl the token against localhost in under a minute. The second reason is the key material. A signing secret or private key pasted into a server-side tool is a secret somebody else has seen — and a JWT signed with a leaked key is a forged token waiting to happen. Here the signing runs in the tab with Web Crypto, nothing is uploaded, and the Network tab shows zero requests; use a throwaway test secret or test key pair and the risk is zero either way. The third reason is the decode preview: the page shows the header and payload exactly as minted, so a typo in a claim (a string where the server expects a number, an exp in milliseconds instead of seconds) is visible before the token ever reaches the API. And because the RSA Key Generator page on this site makes the key pair, the two pages together cover the whole RS256 workflow — generate the pair, sign here, verify on the server — with no other tool involved.
When should you use this tool?
Use it to mint a test token for a local API: HS256 with a throwaway secret, claims sub + role, then curl it against localhost and watch your auth middleware accept it. Use it to test an RS256 flow end to end: generate a key pair on the RSA Key Generator page, sign here with the private PEM, and hand the public PEM to the verifier. Use it to check what a token actually contains before you send it — the decode preview shows the claims as minted, which catches exp-in-milliseconds and wrong-type mistakes. Do not use it for production tokens: real tokens come from your identity provider or backend, with keys stored securely, short expiry, and proper issuer and audience checks. Do not use it to decode or verify tokens from other systems — that is the JWT Decoder page's job.
Key Benefits
- Twelve signing algorithms in one place: HS256/384/512, RS256/384/512, PS256/384/512, ES256/384/512 — most generator pages offer HMAC only.
- Key-pair signing without leaving the site: generate a throwaway test pair in the page, or paste the private PEM from the RSA Key Generator.
- Claim picker with sensible defaults — exp is now + 1 hour, iat is now — so a minted token works immediately.
- Decode preview of the token as minted: catch a wrong claim type or an exp in milliseconds before the token reaches the API.
- Live expiry countdown — see when your test token dies, to the second.
- alg: none is refused by design — the page will not mint an unsigned token.
- Copy and download the token, and a direct link to the JWT Decoder for inspecting it afterwards.
- 100% private: Web Crypto signing in the tab, nothing uploaded, stored, or logged.
Common Use Cases
- Testing a local API's auth middleware: mint an HS256 token with sub and role claims, send it as Authorization: Bearer <token> to localhost, and confirm the middleware accepts it — then change role to a non-admin value and confirm it is rejected.
- Testing an RS256 flow end to end: generate an RSA key pair on the RSA Key Generator page, paste the private PEM here, mint an RS256 token, and verify it server-side with the public PEM — the same pair the verifier will use in production.
- Checking a token before sending it: mint, read the decode preview, and confirm exp is seconds (not milliseconds) and the claims have the types the API expects.
- Debugging an expiry bug: mint a token with exp = now + 60, watch the live countdown hit zero, and confirm your API starts rejecting it at exactly that moment.
- Trying an ES256 token for a mobile or IoT client: generate a P-256 test pair in the page and mint an ES256 token to see the smaller signature size before committing to the curve.
Developer Notes & Best Practices
Minting follows RFC 7515 (JWS) exactly: JSON.stringify the header ({ typ: 'JWT', ...header, alg }) and the payload, Base64url-encode each (no padding), join with '.', and sign the ASCII bytes of that string. HMAC uses crypto.subtle.importKey('raw', secret, { name: 'HMAC', hash }) with SHA-256/384/512; RS* uses importKey('pkcs8', der, { name: 'RSASSA-PKCS1-v1_5', hash }) and sign with the same name; PS* uses RSA-PSS with saltLength equal to the hash length (32/48/64 bytes, the RFC 7518 default); ES* uses importKey('pkcs8', der, { name: 'ECDSA', namedCurve }) — Web Crypto returns ECDSA signatures in raw r||s form, which is exactly the JWS format, so no conversion is needed. PEM parsing strips the BEGIN/END lines and Base64-decodes the body; a missing or malformed PEM produces a plain-language error. The decode preview is a local Base64url decode of the minted token only — it never verifies a signature, and the page links to the JWT Decoder for inspecting tokens from other systems. Correctness was verified in Node 24 (which has Web Crypto): an HS256 token minted with a test secret decodes to the exact payload and verifies with the right secret, fails with a wrong secret, and fails with a tampered signature; RS256, RS384, RS512, PS256, ES256, ES384, and ES512 tokens minted with freshly generated key pairs all verify against their matching public PEMs and fail against a different pair's public key. One design decision worth stating: the page generates RSA test pairs at 2048 bits with public exponent 65537, the same parameters as the RSA Key Generator page.
The three parts of a JWT
| Part | Contents | Encoding |
|---|---|---|
| Header | Algorithm and token type, e.g. { alg: HS256, typ: JWT } | Base64url JSON |
| Payload | Claims: sub, exp, iat, and your own names | Base64url JSON |
| Signature | HMAC or RSA/ECDSA signature over header.payload | Base64url bytes |
HS* vs RS*/PS* vs ES*
| HS256/384/512 | RS256/384/512 | PS256/384/512 | ES256/384/512 | |
|---|---|---|---|---|
| Key | One shared secret | RSA key pair | RSA key pair | EC key pair |
| Sign / verify | Same secret both sides | Private signs, public verifies | Private signs, public verifies | Private signs, public verifies |
| Padding | — | PKCS#1 v1.5 | PSS (randomised) | — |
| Best for | One service's own tokens | Widest compatibility | Strongest RSA padding | Small keys, mobile/IoT |
| Signature size | 32–64 bytes | 256 bytes (2048-bit key) | 256 bytes (2048-bit key) | 64–132 bytes |
Registered claims (RFC 7519)
| Claim | Meaning | Example |
|---|---|---|
| iss | Issuer — who signed the token | "trytoolsnow" |
| sub | Subject — who the token is about | "1234567890" |
| aud | Audience — who the token is for | "my-api" |
| exp | Expiry — seconds since epoch | now + 3600 |
| iat | Issued at — seconds since epoch | now |
| nbf | Not valid before — seconds since epoch | now |
| jti | JWT ID — unique per token | "test-token-1" |
- Mint test tokens with test secrets and test keys only — never paste a production secret or private key into any website.
- Always set exp: a token without one never expires. An hour is a good test default; production access tokens are often 5–15 minutes with a refresh token.
- Keep secrets out of claims: the payload is Base64url, readable by anyone — put an identifier like sub in the token and look the rest up server-side.
- Use RS256 or ES256 when several services must verify your tokens; use HS256 only when one system both signs and checks.
- Check the decode preview before sending the token: exp in seconds (not milliseconds), claim types matching what the API expects.
- Throw test keys away when the test is done, and never reuse a test token in production.
Common Mistakes
- Putting secrets or personal data in claims: the payload is Base64url, not encrypted — anyone who sees the token reads it.
- Using exp in milliseconds: exp and iat are seconds since the epoch. A millisecond value makes the token look valid for about 500 years.
- Using a test token in production: real tokens come from the identity provider or backend, with keys stored securely — never from a web page.
- Pasting a production private key into a generator: the key is compromised the moment it leaves your control — generate a fresh test pair instead.
- Offering or accepting alg: none: an unsigned token is a vulnerability, not a convenience — this page refuses to mint one, and your verifier should refuse to accept one.
- Verifying an RS256 token with the private key (or signing with the public key): the private key signs, the public key verifies — the other way round never works.
Limitations
This page mints test tokens only. It does not verify signatures — verification needs the secret or public key and belongs on the verifier's side (the JWT Decoder page inspects tokens without verifying them either; a full verifier is a separate tool). It does not encrypt payloads: JWTs are signed, not encrypted, so anything in the claims is readable by anyone who sees the token — if the payload itself must stay secret, you need JWE, which this page does not make. RS*/PS*/ES* test pairs are generated at 2048-bit RSA / P-256, P-384, P-521 curves; there is no 4096-bit option in the page (the RSA Key Generator page makes those). The page cannot tell you whether a token your server rejected is malformed, expired, or signed with the wrong key — it can only show you exactly what it minted, so compare the minted claims with what the server expects.
Structured Input/Output Example
Header: { "alg": "HS256", "typ": "JWT" }
Payload: { "sub": "1234567890", "name": "John Doe", "admin": true, "iat": 1516239022, "exp": 1516242622 }
Secret (HS256): your-256-bit-secret — or a PKCS#8 private key for RS*/PS*/ES*Token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWUsImlhdCI6MTUxNjIzOTAyMiwiZXhwIjoxNTE2MjQyNjIyfQ.<signature> Decode preview: header and payload as minted, plus "Expires in 0h 59m 41s"
Related Tools
JWT Decoder Offline
JWT decoder offline: inspect a token’s header, payload claims, and expiry as readable JSON. 100% client-side — production tokens never leave your browser.
RSA Key Generator
RSA key generator: RSA 2048/3072/4096, ECDSA and Ed25519 key pairs in your browser via Web Crypto — PEM, JWK and OpenSSH export, SHA-256 fingerprint.
Unix Timestamp Converter
Unix timestamp converter: turn epoch seconds or milliseconds into local time, UTC, and relative times. Auto-detects seconds vs milliseconds.
Base64 Encoder
Base64 encoder: encode text into Base64 for data URIs, HTTP auth headers, and binary-safe transport. Free, fully offline — tokens never touch a server.
Hash Generator
Hash generator: type any text and get its MD5, SHA-1, and SHA-256 digests side by side in real time. Compare algorithms at a glance. Free, offline.