Skip to content

JWT Generator

Create JSON Web Tokens from a custom header and payload and sign them with HS256, HS384 or HS512 using your own secret.

Runs in your browser Free, no sign-up
Loading tool workspace...

What is JWT Generator?

JWT Generator creates JSON Web Tokens (JWTs) from a header and payload you write yourself, and signs them with your secret using HMAC: HS256, HS384 or HS512. A JWT is three Base64URL-encoded parts joined by dots: the header (algorithm and type), the payload (claims such as sub, name, iat and exp) and the signature. A server verifies the signature with the same secret before it trusts the claims.

Use it to make test tokens for an API you are building, to reproduce a token from a bug report, or to check how your authentication middleware handles expired or tampered tokens. The default header, payload and secret match the well-known example on jwt.io, so you can compare the result there.

How to use JWT Generator

  1. Edit the header JSON: set "alg" to HS256, HS384 or HS512 and keep "typ": "JWT".
  2. Edit the payload JSON with the claims you need, such as "sub", "name", "iat" and "exp" (times are Unix timestamps in seconds).
  3. Enter the secret your server uses to verify tokens.
  4. Click Generate Token and copy the signed JWT.
  5. Send it in an Authorization: Bearer header, or paste it into the JWT Decoder to double-check the claims.

Key features

  • Signs tokens with HS256, HS384 or HS512 (HMAC with SHA-2)
  • Free-form header and payload JSON for any custom claims
  • Spec-compliant Base64URL encoding, as in RFC 7519
  • Tokens verify with jwt.io and standard JWT libraries
  • Signing uses the Web Crypto API; the secret never leaves your browser
  • One-click copy of the finished token

Common use cases

  • Creating test tokens while developing an API locally
  • Testing how middleware treats expired (exp) or not-yet-valid (nbf) tokens
  • Reproducing authorization bugs that depend on specific roles, scopes or tenant IDs
  • Generating bearer tokens for Postman, Insomnia or curl requests
  • Learning how JWT signatures are calculated

Technical details & standards

Tokens are built as described in RFC 7519 (JWT) and RFC 7515 (JWS): the header and payload are serialized as compact JSON, encoded with Base64URL without padding and joined with a dot, and that exact string is signed with HMAC-SHA-256, HMAC-SHA-384 or HMAC-SHA-512 using the browser's Web Crypto API. The Base64URL-encoded signature becomes the third part of the token.

Only the HMAC algorithms are supported. RS256, ES256 and other public-key algorithms sign with a private key and are not available here. Signing happens entirely in your browser, so the secret is never transmitted.

Generate an RS256 JWT in Node.js

This generator signs with a shared secret (HS256, HS384 or HS512). Tokens signed with an RSA private key, RS256, are best made on your own machine so the key never leaves it. Node's built-in crypto module is enough; create a key pair first with openssl genpkey -algorithm RSA -out private.pem and openssl rsa -in private.pem -pubout -out public.pem.

JavaScript (Node.js 16+)

const crypto = require("crypto");
const fs = require("fs");

const b64url = obj => Buffer.from(JSON.stringify(obj)).toString("base64url");
const header = b64url({ alg: "RS256", typ: "JWT" });
const payload = b64url({ sub: "123", exp: Math.floor(Date.now() / 1000) + 3600 });
const signature = crypto
  .sign("RSA-SHA256", Buffer.from(`${header}.${payload}`), fs.readFileSync("private.pem"))
  .toString("base64url");

const jwt = `${header}.${payload}.${signature}`; // starts eyJhbGciOiJSUzI1NiIs…

Anyone with public.pem can verify the token, which is why RS256 suits tokens checked by several services. Paste the result into the JWT Decoder to read its claims.

Frequently asked questions

Is the generated JWT really signed?

Yes. The signature is an HMAC of the header and payload computed with your secret, so any JWT library (jsonwebtoken, PyJWT, jose, java-jwt and others) configured with the same secret and algorithm will verify it.

Which signing algorithms are supported?

HS256, HS384 and HS512, which all use a shared secret. Public-key algorithms such as RS256 and ES256 are not supported because they require a private key.

How do I give the token an expiry time?

Add an "exp" claim containing a Unix timestamp in seconds, for example "exp": 1767225600 for 1 January 2026 00:00 UTC. Servers reject the token after that moment. The Unix Timestamp Converter helps you check what a timestamp means.

Should I use my production secret here?

Signing runs locally and nothing is uploaded, but as a habit, use test secrets in any online tool and keep production secrets in your secret manager or environment configuration.

Can I generate an RS256 JWT token online here?

No. This generator supports HS256, HS384 and HS512, which use a shared secret. RS256 needs an RSA private key, which should not be pasted into any website; the Node.js example above signs RS256 tokens locally with the built-in crypto module.

Is my data safe?

Processing happens locally in your browser. Tool input is not sent to CodeUnpack servers.

Does it work offline?

Once the page has loaded, this tool can process input without an internet connection.

More crypto & security tools

View all