Skip to content
ToolZone

JWT Generator

Create a signed JSON Web Token from a custom payload and secret key, useful for testing authentication flows during development.

Runs in your browser. Nothing you enter or upload leaves your device.

Keyboard shortcuts

Run the main action
⌘ / Ctrl + Enter
Copy the result
⌘ / Ctrl + Shift + Enter
Download the result
⌘ / Ctrl + S
Paste a file or image into file tools
⌘ / Ctrl + V
Search all tools
⌘ / Ctrl + K
Show these shortcuts
?

You can also drop files anywhere on the page.

About the JWT Generator

The JWT Generator creates a signed JSON Web Token from a header and payload you write and a secret key you choose. It is meant for developers testing authentication code, mocking an identity provider, or learning how JWT signatures are built.

How it works

The header text and payload text are each encoded as UTF-8 and then as Base64URL (standard Base64 with + and / replaced by - and _, and the = padding removed). They are joined with a dot to form the signing input.

That string is signed with HMAC-SHA256 using your secret key through the browser's Web Crypto API, and the signature is Base64URL-encoded and appended after a second dot. The signature is always HMAC-SHA256, so the header's alg should be HS256. The text you type is encoded exactly as written, including any spaces, so the tool does not reformat or validate your JSON.

How to use

  1. 1

    Edit the Header (JSON) box; keep "alg":"HS256".

  2. 2

    Write your claims in the Payload (JSON) box.

  3. 3

    Enter the Secret key your application uses to verify tokens.

  4. 4

    Click Generate JWT, then copy the token from the box below.

Worked examples

The default example

Clicking Generate JWT without changing anything.

Input
Header: {"alg":"HS256","typ":"JWT"} Payload: {"sub":"1234567890","name":"John Doe","iat":1516239022} Secret: your-256-bit-secret
Result
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c

This matches the widely used sample token, which is a handy check that signing works as expected.

An admin test token with an expiry

Testing an admin-only endpoint locally.

Input
Payload: {"sub":"user_42","role":"admin","exp":1767225600} Secret: test-secret
Result
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ1c2VyXzQyIiwicm9sZSI6ImFkbWluIiwiZXhwIjoxNzY3MjI1NjAwfQ.9o-wwulsPBWN_dIxBs8fqsfPEFKGQVFPpnDPKfYAHSI

exp 1767225600 is January 1, 2026 00:00:00 UTC, so a server checking expiry will reject this token after that moment.

Limitations
Only HMAC-SHA256 signing is supported; changing alg in the header to HS512 or RS256 does not change the algorithm, so such tokens will fail verification. The header and payload are not checked for valid JSON before encoding. The secret is used as UTF-8 text; Base64-encoded secrets are not decoded first.
Assumptions
The verifying application uses HS256 with the same secret string.
Privacy
Tokens are encoded and signed in your browser with the Web Crypto API; the header, payload and secret are not sent to a server or saved.

Frequently asked questions

Should I use this to generate production tokens?+

No. It is meant for testing and learning. Production tokens should be issued by your server or identity provider, with the signing key kept out of browsers.

What's the difference between the header, payload and signature?+

The header names the algorithm and token type, the payload holds the claims, and the signature is an HMAC of the first two parts that proves they have not been changed.

Which signing algorithms are supported?+

Only HS256 (HMAC with SHA-256). Keep "alg":"HS256" in the header so the token describes itself correctly.

Why does my server say the signature is invalid?+

Check that the secret matches exactly, including case and trailing spaces, that the server expects HS256, and that it does not expect the secret to be Base64-decoded first.

Does the token expire automatically?+

Only if your payload includes an exp claim and the receiving server checks it. The generator does not add any claims for you.

Related tools