Browser-based developer tool · keys and secrets never leave this tab

JWT Generator and Verifier

Assemble a header and claims, sign a JSON Web Token with a secret or a private key, generate a test key pair, and check any token against a key. To read what is inside a token instead, use the JWT decoder.

Decode a token instead
Signing happens in this page with the browser's WebCrypto; nothing is sent anywhere and keys are not saved. A JWT payload is only encoded, so anyone with the token can read the claims. Keys generated here are fine for testing; for production, create them where your secrets are managed.

1. Algorithm and key

2. Header

3. Claims

Times are Unix seconds, calculated when you press Sign. Fields left empty are omitted; they override a same-named claim in the custom JSON.

Header preview
{
  "alg": "HS256",
  "typ": "JWT"
}
Payload preview (at 6:44:02 AM)
{
  "role": "admin",
  "iat": 1795934642,
  "exp": 1795938242,
  "iss": "https://auth.example.com",
  "sub": "user-123",
  "aud": "api.example.com"
}

4. Signed token

Press Sign token. Header, payload and signature appear here in red, purple and blue, joined by dots.

JWT Generator and Signature Verifier

Operator: Abdulla Al Fahad. How tools are built and checked

A JSON Web Token is three base64url pieces joined by dots: a header naming the algorithm, a payload of claims, and a signature over the first two. Reading one is easy, which is what the JWT decoder on this site does. Making one that a real verifier accepts is fussier: the claims need correct Unix times, the secret needs the right length and encoding, RSA and EC keys arrive in several PEM layouts, and ECDSA signatures must be the raw r and s values rather than the DER form most libraries emit by default.

This page builds and signs tokens with the browser's own WebCrypto, so it is the quick way to get a token for a curl test, a staging API or a unit-test fixture. It also generates a key pair when you do not have one, hands back the public half as PEM and JWK, and has a second tab that verifies a token against a secret or a public key.

Key features

  • Twelve algorithms: HS256, HS384, HS512, RS256, RS384, RS512, PS256, PS384, PS512, ES256, ES384 and ES512
  • Claims helper for iat, nbf and exp as now, an offset in seconds, minutes, hours or days, or an exact date; plus iss, sub, aud (one value or a list), a random jti and free-form custom JSON
  • Secrets entered as UTF-8 text or as base64/base64url bytes, with a one-click random secret sized to the hash output
  • Private keys accepted as PKCS#8, PKCS#1 RSA or SEC1 EC PEM; the older layouts are rewrapped to PKCS#8 in the browser
  • Key pair generation for RSA 2048, 3072 and 4096 bits and curves P-256, P-384 and P-521, with public PEM, public JWK and private PEM downloads
  • Verification against a secret, a public PEM, a public JWK or JWK set, or a private PEM from which the public half is derived

Algorithms, key formats and how verification is pinned

The signing input is the base64url of the header JSON, a dot, then the base64url of the payload JSON, and the signature is computed over exactly those ASCII bytes. HS algorithms are HMAC with SHA-256, 384 or 512. RS algorithms are RSASSA-PKCS1-v1_5 with the matching hash. PS algorithms are RSA-PSS, and RFC 7518 fixes the salt length at the hash size, which is 32, 48 or 64 bytes. ES algorithms are ECDSA on P-256, P-384 and P-521 with SHA-256, 384 and 512; WebCrypto returns the signature as r and s concatenated (64, 96 or 132 bytes), which is the form JWS requires, so no DER conversion is involved.

An HMAC key should be at least as long as the hash output: 32 bytes for HS256, 48 for HS384, 64 for HS512 (RFC 7518 section 3.2). The page measures the secret in bytes after decoding, so a 32-character base64 string that decodes to 24 bytes is flagged as short for HS256, and a list of well-known secrets such as secret, password and your-256-bit-secret is flagged as an error. If the secret field is set to base64, the decoded bytes are the key, which is what most libraries mean by a base64 secret.

Private keys are read from PEM. A block labelled PRIVATE KEY is PKCS#8 and is used as is. RSA PRIVATE KEY (PKCS#1) and EC PRIVATE KEY (SEC1) are wrapped into a PKCS#8 envelope in the page, using the curve named inside the SEC1 structure. Passphrase-protected keys and certificates are refused with the openssl command that converts them. An ES256 token needs a P-256 key; offering a P-384 key is reported as a curve mismatch rather than silently signing with the wrong algorithm.

Verification pins the algorithm. The algorithm you select is the one enforced and the token's own alg header must equal it; a header of none is reported as an unsigned token, and an HS256 header is not allowed to turn an RSA public key into an HMAC secret, which is the classic algorithm-confusion attack. After the signature check the page lists exp and nbf against the current time as information. It does not check iss or aud, because those depend on what your application expects.

How it works

Press Sign token and the claims are resolved against the current clock, so a relative exp is measured from that moment, not from when you last edited the form. The header and payload are serialised with JSON.stringify, base64url-encoded, signed through crypto.subtle.sign, and shown in three colours. Generated keys are created with crypto.subtle.generateKey as extractable keys so they can be exported, and live only in the page's memory: nothing is written to localStorage and nothing is uploaded.

Typical uses

  • Minting a one-hour RS256 token with sub, aud and a role claim to call a staging API from curl
  • Producing an already-expired token or one with a future nbf to test how a service rejects them
  • Generating an ES256 key pair and publishing the public JWK in a JWKS file for an identity-provider test
  • Checking whether a token from a colleague was really signed with the shared HS256 secret
  • Reproducing a failing signature by verifying the token against the public key your service actually loads

Building one

  1. Choose the algorithm. For HS algorithms enter or generate a secret; for RS, PS and ES paste a private PEM or press Generate key pair.
  2. Set the header fields (typ, optional kid) and the claims, using the helper for iat, exp and nbf and the custom JSON box for anything else.
  3. Press Sign token, then copy the token or the ready-made Authorization header.
  4. To check it, press Verify this token, or open the Verify tab, paste any token, confirm the expected algorithm and give the secret or public key.

Example

HS256 with a fixed clock

Header: {"alg":"HS256","typ":"JWT"}
Payload: {"sub":"user-123","iat":1700000000,"exp":1700003600}
Secret (UTF-8): a-string-secret-at-least-256-bits-long

Signed token

eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.
eyJzdWIiOiJ1c2VyLTEyMyIsImlhdCI6MTcwMDAwMDAwMCwiZXhwIjoxNzAwMDAzNjAwfQ.
CLm-4gEGRV881EDFTR3UNWbXK-PnCqCsmQJh5wTGZZw
(the secret is 38 bytes, so the HS256 length check passes; with a different clock only iat and exp, and so the last two parts, change)

Tips for best results

  • Give every token an exp. The page warns when it is missing, in the past, or more than a year away, because bearer tokens are hard to revoke.
  • For an ES token that a Java or .NET library rejects, check the curve first: ES384 needs P-384 and ES512 needs P-521, not P-256.
  • If your service reads a base64 secret, switch the secret box to base64; the same text means different key bytes in the two modes and gives a different signature.

Things to check before you rely on it

The payload is readable by anyone holding the token. Do not put passwords, API secrets or personal data in claims; the page warns about claim names that look sensitive.

Keys generated here are for testing. They exist in a browser tab on a machine you do not manage as a secrets vault; create production keys in your KMS or with openssl on a controlled host.

A valid signature only proves the token was signed with that key. It does not mean the token is acceptable: expiry, issuer, audience and revocation are checks your application must still make.

Encrypted tokens (JWE, five parts) are not supported; this tool handles signed tokens only, and the verifier says so when it meets one.

Common errors and how to fix them

"That is a public key. Signing needs the private key"
Paste the block that begins -----BEGIN PRIVATE KEY----- (or RSA PRIVATE KEY or EC PRIVATE KEY). The public key is only used on the Verify tab.
"This key is encrypted with a passphrase"
Remove the passphrase first with openssl pkey -in key.pem -out key-plain.pem, then paste the plain key.
"The token header says RS256 but you are verifying with HS256"
Select the algorithm the token was signed with. The mismatch is reported on purpose: a verifier should never let the token choose the algorithm.
"The key could not be used for ES256. It must be an EC key on curve P-256"
Generate or paste a P-256 key for ES256, a P-384 key for ES384 or a P-521 key for ES512.

Best practices

  • Pin the algorithm in your own verifier the same way the Verify tab does, and reject tokens whose header says none.
  • Prefer asymmetric algorithms when the verifying service is not the one issuing tokens, so verifiers hold only a public key.

Choosing between HS, RS, PS and ES

HMAC is the simplest and the fastest, and fits a single service that both issues and checks its own tokens, because the same secret does both. As soon as a second service needs to verify, sharing the secret means that service can also forge tokens, and an asymmetric algorithm is the better fit.

RS256 is the most widely supported asymmetric choice and what most identity providers default to. PS256 is the same RSA key with a probabilistic padding and a stronger security proof, but fewer libraries accept it. ES256 gives much shorter keys and signatures, about 64 bytes against 256 for RSA 2048, at the cost of slightly less universal support in older stacks.

Frequently asked questions

How is this different from the JWT decoder?

The JWT decoder inspects a token you already have. This page creates tokens, signs them with a key you provide or generate, and verifies a signature against a key.

Why is my HS256 secret flagged as too short?

RFC 7518 asks for a key at least as long as the hash output, 32 bytes for HS256. The check counts bytes after decoding, so a base64 secret is measured by what it decodes to, not by how many characters you typed.

Can I sign with a key from openssl or ssh-keygen?

Yes if it is a PEM RSA or EC private key in PKCS#8, PKCS#1 or SEC1 form. OpenSSH-format keys (-----BEGIN OPENSSH PRIVATE KEY-----) are not read; convert them with ssh-keygen -p -m PKCS8 first.