Skip to content
Developer

JWT Generator

Generate signed JSON Web Tokens (HS256) with custom claims.

jwttokengeneratesignhs256
Loading tool…

Recommended tools

Affiliate links — we may earn a commission if you sign up.

About the JWT Generator

JWT Generator mints signed JSON Web Tokens using the HS256 algorithm, which pairs HMAC with SHA-256 for a compact, tamper-evident token. Provide a Secret key, which powers the signing and can be shown or hidden with the eye toggle, then edit the Header JSON and Payload JSON textareas to control the token contents. Clicking Generate JWT signs the token entirely in your browser through the Web Crypto API, so the secret never leaves your machine. The sample header and payload are preloaded, and the generator fires once on first load so you can see a working token immediately. The Reset button restores the default header and payload while clearing the secret, and a red alert explains failures like a missing secret or JSON that will not parse. Four stat tiles track the Algorithm, Secret bytes, Header bytes, and Token bytes so you can watch the size impact of your claims. The finished token appears in the ResultBox and can be copied or downloaded as token.jwt. This is a client-side tool built for development and testing rather than production signing.

Hand-written guide

Examples

Input
Secret your-256-bit-secret, header {"alg":"HS256","typ":"JWT"}, payload with sub, name, iat, and exp claims.
Output
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkZlcm5hbmRlcyBMYWJzIiwiaWF0IjoxNzAwMDAwMDAwLCJleHAiOjE4MDAwMDAwMDB9.iQGIEeRjOFm4ZgzoAJrypUWpu_cJURN9elCljM5BJ80
Note: Generated on first load with the preloaded header, payload, and placeholder secret, while the Secret bytes stat reads 19.
Input
Secret ratchet-secret, header {"alg":"HS256","typ":"JWT"}, payload:
{
  "sub": "user_42",
  "role": "admin",
  "scope": ["read", "write"],
  "iat": 1710000000,
  "exp": 1713600000
}
Output
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ1c2VyXzQyIiwicm9sZSI6ImFkbWluIiwic2NvcGUiOlsicmVhZCIsIndyaXRlIl0sImlhdCI6MTcxMDAwMDAwMCwiZXhwIjoxNzEzNjAwMDAwfQ.-n64S1Dz7434Lo88XpXfm7b2z3_X5SqkJ8E0IohgKy8
Note: Adding a role and a scope array to the claims visibly grows the Token bytes stat against the default example.
Input
Secret left empty, default header and payload, then Generate JWT.
Output
No token — a red alert says Secret is required to sign the JWT. and a toast reads Secret is required.
Note: Generate JWT refuses to sign without a key, clearing the token box until a secret is supplied.

How to use

  1. 1

    Enter a Secret key in the Secret key field; use the eye icon to reveal or hide the value while typing.

  2. 2

    Edit the Header JSON and Payload JSON textareas, keeping both valid and alg set to HS256.

  3. 3

    Click Generate JWT to sign the token with HMAC-SHA256 entirely in your browser.

  4. 4

    If an error appears, read the red alert, which names empty secrets or invalid JSON blocks.

  5. 5

    Copy the token from the JWT token result box or download it as token.jwt; Reset restores the defaults.

Common use cases

  • Creating a test token for a development-only API using the placeholder claims.
  • Signing tokens with a shared secret to exercise an SSO flow against a local stub.
  • Generating short-lived tokens to verify expiry handling in your application.
  • Producing a token for load tests that bypasses the login form.
  • Exploring how payload size affects the final token byte count.
  • Building a sample token for your decoder tooling or API documentation.

Best practices

  • Use a secret of 32 bytes or more, generated securely, since HS256 strength depends on key entropy.
  • Keep the secret environment-specific and out of source control, because the same key signs every token you issue.
  • Validate the generated token by decoding it in the JWT Decoder and checking header, claims, and byte sizes.
  • Set exp on every payload so signed tokens expire instead of living forever.
  • Keep the Secret key masked behind the show-hide toggle and never type it in a screen-shared session.
  • Generate test tokens with short expiry so any leaked sample becomes worthless quickly.

Tips

  • Match the secret length to the algorithm — for HS256 aim for at least 32 bytes of key material.
  • After generating a test token, decode it in the JWT Decoder to confirm the header and claims look right.
  • Keep the Secret key field masked unless you are demoing, and use the eye toggle only when needed.
  • Reset clears the secret too, so re-enter it whenever you continue work in a fresh session.

Frequently asked questions

Verification is not included. The tool only signs tokens with HS256 using the Web Crypto API, so it never checks the authenticity of a token you supply. For verification, paste the result into a decoder or test it in your application, since the same key must reproduce the same base64url signature.

Explore more developer tools

Browse the full collection of developer tools on the hub, or jump back to all categories.

Related tools