Unsigned token
It has no signature, and any correctly configured server must reject it. Use it only to test that your server does.
Header
Payload
Signing key
Use test keys only. Treat any real secret or private key you paste into a website as exposed, and rotate it.
Without "Let me copy the private key", a generated private key stays locked inside the browser: it can sign here, but not be read or copied. Tick it before generating if you need the key elsewhere.
Encoded token
Public key (for verifying)
Warnings and notes
Test scenarios
Make a set of good and bad tokens from your header, payload and key, to check that your server accepts the right ones and rejects the rest. The wrong issuer and audience differ from the expected values below.
| Scenario | Change | A correct server | Token |
|---|
Ctrl+Enter run / or Ctrl+K search tools Press Ctrl+D to bookmark this page
How to create a JWT
- Pick the algorithm. The header's
"alg"follows it, and typing another algorithm in the header changes the list too, so the token can never claim one algorithm and be signed with another. - Edit the payload, the claims your server will read. The buttons under it set
iat,expandnbfto times relative to now and add a randomjti, and every time claim is shown as a local and a UTC date. - Give it a key. For HS algorithms enter a secret or press Generate secret. For RS, PS, ES and EdDSA paste a private key, or press Generate test key pair.
- The token is signed as you type. Copy it, copy it as an
Authorization: Bearerheader, or open it in the JWT Decoder, which receives the public key too so it can show the signature as verified.
While you type, the token is marked "Updating…" and its buttons are turned off, so you can never copy a token that no longer matches your inputs. If an input becomes invalid, the old token is removed and the error is shown in its place.
How a signed JWT is built
A JWT is three pieces of Base64URL text joined by dots: header.payload.signature.
- The header and payload are written as compact JSON and each is Base64URL-encoded (letters, digits,
-and_, with no=padding). - The two are joined with a dot. That exact text is what gets signed.
- The signature is made with the secret or private key, Base64URL-encoded, and added after a second dot.
Two details trip people up. ECDSA signatures in a JWT are the raw r and s values joined together (64 bytes for ES256), not the DER format many crypto libraries return by default. RSA-PSS uses a salt as long as the hash: 32 bytes for PS256. This tool does both, and numbers in your payload are kept exactly as you typed them, even beyond JavaScript's safe integer range.
Choosing an algorithm and a key
| alg | Signs with | Notes |
|---|---|---|
HS256, HS384, HS512 | A shared secret | At least 32, 48 or 64 random bytes. The same secret verifies, so every verifier could also make tokens. |
RS256, RS384, RS512 | An RSA private key | Use 2048 bits or more. The most widely supported public-key choice. |
PS256, PS384, PS512 | An RSA private key | RSA with PSS padding. The same RSA key works for RS and PS. |
ES256, ES384, ES512 | An EC key on P-256, P-384 or P-521 | Each algorithm has exactly one curve. Small keys and short tokens. |
EdDSA | An Ed25519 key | Fast and modern. Available where your browser supports Ed25519. |
none | Nothing | An unsigned token, only for testing that servers reject it. |
Private keys can be pasted as PKCS#8 (BEGIN PRIVATE KEY), the older PKCS#1 (BEGIN RSA PRIVATE KEY) and SEC1 (BEGIN EC PRIVATE KEY) formats, which are converted in your browser, or as a private JWK. The key must fit the algorithm: an RSA key cannot sign ES256, and a P-384 key cannot sign ES256. A mismatch is explained instead of tried.
The matching public key is shown as PEM and JWK, so you can put it on your test server. It is read from the private key text itself, so the private key is never exported to do it.
Test scenarios for your server
A server that accepts good tokens is only half tested. Generate test tokens makes a set of tokens from your header, payload and key, each with what a correctly configured server should do with it:
- Valid (baseline): Your claims, issued now and not expired. A correct server accepts it; if it does not, the other results mean nothing.
- Expired: "exp" an hour in the past.
- Not yet valid: "nbf" an hour in the future.
- Missing exp: No expiry at all. Servers should require one.
- Wrong audience and wrong issuer: "aud" or "iss" changed to a value that differs from the one you expect.
- Invalid signature: Signed correctly, then one bit of the signature changed.
- Unsigned: "alg": "none" and no signature. Only when unsigned tokens are switched on.
Enter the issuer and audience your server expects first. Copy all as JSON gives a list of scenario, token and expect entries you can paste into an automated test. The times are relative to the moment you generate them, so generate them again when you rerun your tests.
Warnings the tool shows
- Weak secrets: shorter than the hash (RFC 7518 requires at least 32 bytes for HS256), on lists of well-known defaults such as "secret" or "your-256-bit-secret", or simple patterns such as one word or only digits. These can be cracked offline from a single token.
- Real credentials: a secret that starts like a live API key from another service, a key you pasted rather than generated, and an issuer or audience on a real domain rather than a test one such as
localhost,*.testorexample.com. - Token problems: no
exp, a lifetime over 30 days, duplicate keys, and sensitive-looking fields such aspassword, which anyone with the token can read.
Warnings never stop you from signing: test tokens are often odd on purpose. Errors, in red, mean no token can be made, and say exactly why, with the line and column for JSON mistakes.
Safety: use test keys only
Signing needs the one thing that must never leak: the secret or the private key. Anyone who has it can make tokens your server will accept. So even though everything on this page runs in your browser, with nothing sent, saved or put in a link, treat any real secret or private key you paste into any website as exposed, and rotate it.
The safest way to use this page is with the keys it makes for you. Generated private keys stay locked inside the browser unless you tick Let me copy the private key before generating, and they disappear when you leave the page. To make test keys on your own machine instead:
- HS256 secret:
openssl rand -base64 32 - RSA key:
openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -out key.pem - EC P-256 key:
openssl genpkey -algorithm EC -pkeyopt ec_paramgen_curve:P-256 -out key.pem - Its public key:
openssl pkey -in key.pem -pubout
To check the privacy claim yourself, open your browser's developer tools, choose the Network tab, then sign a token and generate a key: no request is made. This page is for testing, documentation and learning. Issue production tokens on your server with a maintained JWT library and a key that never leaves it.
Frequently asked questions
Is my secret or private key sent anywhere?
No. Signing and key generation use your browser's built-in Web Crypto API, and the page makes no network request with your claims, secret or key. Nothing is saved or put in a link. Even so, use test keys only: treat any real key pasted into a website as exposed.
How long should an HS256 secret be?
At least 32 random bytes, the length of the SHA-256 hash (RFC 7518). HS384 needs 48 and HS512 needs 64. Generate secret makes one of the right length. Words, short passwords and defaults like "secret" can be cracked offline from one token.
Where do I get a private key for RS256 or ES256?
Press Generate test key pair to make one in your browser, or create one with openssl on your own machine. Paste it as PKCS#8, PKCS#1, SEC1 or a private JWK. The matching public key is shown for your test server.
Why does my ES256 or PS256 token change every time?
ECDSA and RSA-PSS add randomness to each signature, so the same header and payload give a different token on every signing. All of them are valid. HS and RS tokens are deterministic and stay the same.
Why can I not copy the private key I generated?
Generated private keys are locked inside the browser by default, so nothing can read them back. If you need the key elsewhere, tick "Let me copy the private key" and generate a new pair. The browser cannot unlock a key afterwards.
Why would I make an unsigned token?
To check that your server rejects it. A token with "alg": "none" has no signature, so anyone can forge one. Any correct server must refuse it. The checkbox is off every time the page loads.
Is the token encrypted?
No. A signed JWT is only encoded: anyone with the token can read the header and payload. The signature stops changes, not reading. Never put passwords or personal secrets in the payload.
Can I use these tokens in production?
No. This page is for testing, documentation and learning. Production tokens should be issued by your server with a maintained JWT library and a key that never leaves the server.
Create a JWT in your code
Building and signing an HS256 token with only each standard library, in Java, JavaScript, Python and Go. All four print the same token. For other algorithms and for real use, use a maintained JWT library.
Java
// Create an HS256 JWT with the Java standard library (Java 11+).
import java.nio.charset.StandardCharsets;
import java.util.Base64;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
public class JwtSign {
public static void main(String[] args) throws Exception {
byte[] secret = "encoder-demo-secret-32-bytes-min!".getBytes(StandardCharsets.UTF_8); // a test secret, never a real one
// Written as text so the field order is fixed; real code builds it with Jackson or Gson.
String header = "{\"alg\":\"HS256\",\"typ\":\"JWT\"}";
String payload = "{\"sub\":\"user_12345\",\"name\":\"Ada Example\",\"iat\":1795564800,\"exp\":1795568400}";
Base64.Encoder enc = Base64.getUrlEncoder().withoutPadding();
String signingInput = enc.encodeToString(header.getBytes(StandardCharsets.UTF_8))
+ "." + enc.encodeToString(payload.getBytes(StandardCharsets.UTF_8));
Mac mac = Mac.getInstance("HmacSHA256");
mac.init(new SecretKeySpec(secret, "HmacSHA256"));
String signature = enc.encodeToString(mac.doFinal(signingInput.getBytes(StandardCharsets.US_ASCII)));
System.out.println(signingInput + "." + signature);
}
} Standard library only (Java 11+). For RS, PS, ES and EdDSA, and for claim checks, use a JWT library such as jjwt or nimbus-jose-jwt.
JavaScript
// Create an HS256 JWT with Node's standard library.
import { createHmac } from 'node:crypto';
const secret = 'encoder-demo-secret-32-bytes-min!'; // a test secret, never a real one
const header = { alg: 'HS256', typ: 'JWT' };
const payload = { sub: 'user_12345', name: 'Ada Example', iat: 1795564800, exp: 1795568400 };
// Each part is compact JSON, Base64URL-encoded without padding.
const part = (obj) => Buffer.from(JSON.stringify(obj)).toString('base64url');
const signingInput = `${part(header)}.${part(payload)}`;
// The signature is an HMAC-SHA256 of "header.payload" with the shared secret.
const signature = createHmac('sha256', secret).update(signingInput).digest('base64url');
console.log(`${signingInput}.${signature}`); Node.js 16 or later. In a browser, use the Web Crypto API (crypto.subtle.sign). The jose library covers every algorithm.
Python
# Create an HS256 JWT with Python's standard library.
import base64
import hashlib
import hmac
import json
secret = b"encoder-demo-secret-32-bytes-min!" # a test secret, never a real one
header = {"alg": "HS256", "typ": "JWT"}
payload = {"sub": "user_12345", "name": "Ada Example", "iat": 1795564800, "exp": 1795568400}
def part(data: bytes) -> str:
# Base64URL without "=" padding, as JWTs require.
return base64.urlsafe_b64encode(data).rstrip(b"=").decode("ascii")
def compact(obj) -> bytes:
# No spaces, so every language produces the same bytes.
return json.dumps(obj, separators=(",", ":")).encode("utf-8")
signing_input = f"{part(compact(header))}.{part(compact(payload))}"
signature = hmac.new(secret, signing_input.encode("ascii"), hashlib.sha256).digest()
print(f"{signing_input}.{part(signature)}") Standard library only. PyJWT (jwt.encode) does the same in one call and supports RS, PS, ES and EdDSA.
Go
// Create an HS256 JWT with Go's standard library.
package main
import (
"crypto/hmac"
"crypto/sha256"
"encoding/base64"
"fmt"
)
func main() {
secret := []byte("encoder-demo-secret-32-bytes-min!") // a test secret, never a real one
// Written as text so the field order is fixed. With encoding/json, marshal a
// struct (maps are sorted by key, which changes the token).
header := `{"alg":"HS256","typ":"JWT"}`
payload := `{"sub":"user_12345","name":"Ada Example","iat":1795564800,"exp":1795568400}`
enc := base64.RawURLEncoding // Base64URL without padding
signingInput := enc.EncodeToString([]byte(header)) + "." + enc.EncodeToString([]byte(payload))
mac := hmac.New(sha256.New, secret)
mac.Write([]byte(signingInput))
signature := enc.EncodeToString(mac.Sum(nil))
fmt.Println(signingInput + "." + signature)
} Standard library only. golang-jwt/jwt is the common library for every algorithm.
Last verified . Each example is run automatically and its output checked.