JWT Builder

JWT Builder

Generate JSON Web Tokens with custom claims. Support for HS256, HS384, HS512 algorithms. Set expiration, issuer, subject, audience. Free online JWT generator

A JWT builder is mostly useful when you are testing the verifier, not the issuer. You need a token with a specific exp, a specific aud, a specific custom claim — and you need it now, with a fresh signature, without spinning up your auth server. This builder lets you edit the header and payload as JSON, pick HS256/HS384/HS512, supply your secret, and produces the three-segment token ready to paste into an Authorization: Bearer header. Signing happens locally; your secret never leaves the tab.

What this builder produces

Output is a JWS Compact Serialization per RFC 7515: base64url(header) + "." + base64url(payload) + "." + base64url(HMAC-SHA-XXX(key, header + "." + payload)). The base64url variant uses - and _ instead of + and /, and strips trailing = padding. Manually-built tokens that fail verification almost always fail here — standard base64 sneaks in if you build by hand.

Only symmetric HMAC algorithms are offered. Asymmetric signing (RS256, ES256) requires a private key whose handling is outside the scope of a paste-and-build tool — for those, generate keys with ssh-keygen / openssl and sign with a real library so you can test rotation and JWKS lookup at the same time.

Working example

Header and payload as JSON, HS256, secret = "your-256-bit-secret":

Input

Header: { "alg": "HS256", "typ": "JWT" }
Payload: { "sub": "user_42", "iss": "https://eutils.pro", "aud": "api-staging", "exp": 1747353600, "iat": 1747267200 }
Secret: your-256-bit-secret

Output

eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ1c2VyXzQyIiwiaXNzIjoiaHR0cHM6Ly9ldXRpbHMucHJvIiwiYXVkIjoiYXBpLXN0YWdpbmciLCJleHAiOjE3NDczNTM2MDAsImlhdCI6MTc0NzI2NzIwMH0.SIGNATURE

Exact signature depends on your secret. Paste this into Bearer header and watch your verifier accept it — or, more usefully, fail with the specific reason you wanted to test.

Practical patterns

  • Reproduce an "expired token" bug locally — set exp to a past Unix timestamp and confirm your handler returns 401 with the right message.
  • Test audience validation — build a token with aud = "wrong-service" and confirm your verifier rejects it. A common bug is verifiers that ignore aud entirely.
  • Forge a token that should NOT pass — flip a character in the signature and confirm verification fails. If it passes, your library is running in verify-skip mode.
  • Generate a long-lived test token (exp = 4070908800, i.e. year 2099) for CI fixtures, but only with a throwaway secret unique to staging.

Common mistakes this lets you reproduce

  • exp in milliseconds instead of seconds — token "expires" in year 56,084. Verifier accepts it forever, which silently masks expiration logic.
  • Custom claim with a typo — userId vs user_id vs sub — verifier reads undefined and your "feature flag claim" is never honored.
  • Forgetting iat — some libraries require it for replay-window logic, some do not. Build with and without to see what your verifier tolerates.
  • Mismatched typ — setting typ to "at+jwt" (access token JWT per RFC 9068) when your verifier only recognizes "JWT".

What this tool will not do

  • It will not sign with RS256/ES256/PS256. Asymmetric signing needs a private key and a real crypto library; for those, use jose, jsonwebtoken, or the Web Crypto API directly.
  • It will not produce JWEs. Encrypted tokens have five segments and require a recipient public key plus a content encryption algorithm.
  • It will not validate that your claims make sense for a given OIDC profile. Building an id_token without sub and iat is technically valid JWS but will be rejected by spec-compliant verifiers.

Your secret is used only inside this tab via the Web Crypto SubtleCrypto.sign API. It is not transmitted, stored, or logged anywhere by the page. Still, only use throwaway secrets — anything you paste into any web tool should be considered compromised.

Frequently asked questions

How long should my HS256 secret be?

At least 256 bits (32 bytes) of entropy per RFC 7518 §3.2. Anything shorter weakens HMAC-SHA-256 below its design strength. In practice, generate a random 32-byte secret and base64-encode it for storage. Do not use a memorable string.

Why does my verifier reject the token even though the signature should be correct?

Three usual suspects: (1) you base64-encoded the secret in the verifier but pasted the raw string here (or vice versa), (2) the verifier expects a specific typ or alg you did not match, (3) clock skew is making exp/nbf look invalid by a few seconds.

Can I put binary data in the payload?

JWT payloads must be valid JSON, which is UTF-8 text. To carry binary, base64-encode it into a string claim. Do not try to put raw bytes — they will be mojibaked by some JSON parsers.

Is it safe to test with a real production secret?

No. Web tools — including this one — should be considered untrusted boundaries. Generate a staging-only secret, test, and rotate. If you suspect a production secret was ever pasted anywhere outside your secret manager, rotate it.

What happens if I omit alg from the header?

The header alg field is required by RFC 7519. Omitting it is technically invalid. Some libraries default to none (unsigned tokens) which is a serious security antipattern — never accept alg:none in production verifiers.

How do I know my token will fit in an Authorization header?

Most servers limit headers to 8KB total. A typical JWT with a dozen claims is 400–800 bytes. If your payload includes large permission arrays, expect to bump into header limits — consider opaque tokens with a server-side session store instead.

Related tools

Last updated · E-Utils editorial team