🛠️ Developer & Web

JWT Generator

Build and sign a JSON Web Token for testing.

  • HS256/384/512HMAC algorithms
  • Web Cryptosigning in the browser
  • 6expiry presets
  • Key-lengthwarning built in

How to use the JWT Generator

  1. 1

    Write the payload

    Edit the JSON object — for example sub, name, role, scope or any custom claim.

  2. 2

    Choose expiry and iat

    Pick no exp, 15 minutes, 1 hour, 1 day, 7 days or 30 days, and whether to add iat. Both use the current time.

  3. 3

    Enter a test secret

    Type a secret, or tick “Secret is Base64-encoded” if your server stores it that way (Base64URL also works).

  4. 4

    Copy and use the token

    Use it in Postman, curl or tests; open it in the decoder to double-check claims.

Features

Live signing

The token updates with every change to payload, algorithm, secret or expiry.

Valid JSON check

Clear errors if the payload is not valid JSON or not an object.

Weak-secret warning

Warns when the secret is shorter than the hash size (256, 384 or 512 bits).

Base64 secrets

Decode Base64 or Base64URL secrets to raw bytes before signing.

Payload remembered

Your last payload is kept in this browser; the secret is not saved.

Local only

The HMAC is computed with the browser’s Web Crypto API; nothing is sent.

Who uses it — and for what

API testing

Create tokens with specific roles to test authorisation rules.

Expiry testing

Make 15-minute tokens to check refresh flows.

Teaching JWTs

Show how changing one claim changes the signature.

Local development

Stub an auth server while building a front end.

How a JWT is built

A JSON Web Token has three Base64URL-encoded parts separated by dots: a header ({"alg":"HS256","typ":"JWT"}), a payload of claims, and a signature — here an HMAC of the first two parts using your secret. Standard claims include sub (subject/user id), iat (issued at), exp (expiry), iss (issuer) and aud (audience); times are Unix seconds. Anyone can decode a JWT, so never put passwords or secrets in the payload — the signature only proves it wasn’t changed.

For testing only

Use this to create tokens for local development, API testing in Postman or curl, and unit tests. Signing happens with your browser’s Web Crypto API, so the secret never leaves your device — still, don’t paste production signing keys into any website. HS256 secrets should be at least 32 random bytes; generate one with the Password Generator. RS256/ES256 (public-key) tokens need a private key and aren’t covered here.

How the token is assembled

The tool builds the token in four steps, exactly as RFC 7519 describes for HMAC-signed JWTs:

  1. Header JSON {"alg":"HS256","typ":"JWT"} is serialised compactly and Base64URL-encoded.
  2. The payload is parsed, iat and exp are added or overwritten (if you typed your own exp and also picked an expiry, the preset wins), then serialised compactly and encoded.
  3. The two parts are joined with a dot, and HMAC with SHA-256, SHA-384 or SHA-512 is computed over that text using your secret.
  4. The signature bytes are Base64URL-encoded and appended after a second dot.

Because the JSON is re-serialised, whitespace and indentation in your payload box do not affect the token, but key order does — the same claims in a different order give a different signature, which is fine because servers verify the exact bytes they received.

Secrets: length, encoding and what never to paste

For HMAC JWTs, RFC 7518 requires a key at least as long as the hash output: 256 bits (32 bytes) for HS256, 384 for HS384 and 512 for HS512. A memorable phrase is far weaker than its length suggests, so generate random bytes — openssl rand -base64 32 or the password generator — and tick the Base64 option if you paste them in that form.

Watch the encoding. Some frameworks treat the configured secret as plain text, others Base64-decode it first. If your server rejects a token that looks right, try toggling the Base64 option; that mismatch is the most common cause.

Only use test secrets here. Although signing happens on your device and the secret is never stored, a production signing key lets anyone mint valid tokens for every user, so it should stay inside your server or secret manager — not in browsers, chats or screenshots. If one is exposed, rotate it immediately.

HS256 versus RS256 and ES256

HS256 (this tool)RS256 / ES256
Key typeOne shared secretPrivate key signs, public key verifies
Who can create tokensAnyone who can verify themOnly the holder of the private key
Typical useA single service issuing and checking its own tokensIdentity providers and many independent APIs
Signature size32 bytes256 bytes (RSA-2048) or 64 bytes (P-256)

If your API trusts tokens from Auth0, Firebase, Cognito, Keycloak or a similar provider, it almost certainly expects RS256 or ES256 and will reject anything made here. Use the provider’s test users instead.

Worked examples

Default payload, no iat or exp

With the default payload, HS256, the secret your-256-bit-secret, “No exp claim” and iat unticked, the token is:

eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkphbmUgRG9lIiwicm9sZSI6ImFkbWluIn0.Ii9EDpYiUD4iGL-vE3kyj4BhRiwYUWW_Aeuh_uriW-0

The status also warns “secret is only 152 bits — use at least 256”: that placeholder text is 19 characters, i.e. 19 bytes.

Same input, HS512

Switching to HS512 changes the first part to eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9 (the header now says HS512), keeps the identical payload part, and produces an 86-character signature instead of 43 — 64 bytes rather than 32.

Why your token differs every minute

With iat ticked or an expiry chosen, the tool stamps the current time into the payload, so the token changes whenever the clock moves on a second. That is expected: the same claims with a different iat produce a completely different signature.

Pro tips

  • Keep test payloads realistic but fake — use IDs like u_test_1 rather than real customer data.
  • Add iss and aud claims if your server validates them, or the token will be refused even with a correct signature.
  • Paste the result into the JWT decoder to see your exp as a readable date.

Glossary

HMAC
Hash-based message authentication code: a keyed hash proving data was signed with a shared secret.
iat
Issued-at time, in Unix seconds.
exp
Expiry time, in Unix seconds; the token is invalid after it.
Compact serialisation
The header.payload.signature string form of a JWT.

Frequently asked questions

Is a JWT encrypted?

No, a standard JWT is only signed; anyone can read the payload.

What does exp mean?

The expiry time in Unix seconds — servers reject the token after it.

How long should an HS256 secret be?

At least 256 bits (32 random bytes).

Why does my server say the signature is invalid?

Usually the secret differs: check for spaces, whether the server Base64-decodes it, and that the algorithm matches.

Can I create RS256 tokens here?

No. Only HS256, HS384 and HS512 are supported, because RS256 needs a private key.

Is my secret saved?

No. Only the payload text is remembered in this browser; the secret field is not stored.

Found it useful? Share the JWT Generator:

Last updated 2026-11-28 · Built by Vinayak Agarwal · Part of Developer & Web (77 tools)