What does a JWT encoder do?
A JWT encoder builds a JSON Web Token from two JSON objects, the header and the payload, and signs them with a key. The result is three Base64URL parts joined by dots: header.payload.signature. You need one to test an API that expects a Bearer token, reproduce a bug tied to a claim or prepare fixtures for automated tests.
This page opens the JWT decoder and signer ready to create tokens. You edit the header and payload as JSON, choose the algorithm (HS256/384/512 with a shared secret, or RS, PS, ES and EdDSA with a private key), and the token is re-signed every time you change something. Warnings appear when the token is weak: a secret shorter than the algorithm needs, no exp, or alg: none. Keys stay in the page and nothing is sent anywhere.
How to create and sign a JWT
- In Header, pick the Algorithm.
- Write the claims in Payload, for example
sub,name,iatandexp. Dates are seconds since 1970 (Unix time), not milliseconds. - In Key, type the Secret, or click Generate a random secret for a 48-byte random one (it is stored Base64URL-encoded, so the matching box is ticked). For RS, PS, ES or EdDSA, click Generate an example key pair or paste your private key (PKCS#8 PEM or JWK).
- The token at the top is rebuilt a moment after each edit. The status should read Signature valid.
- Click Copy token. The Claims table shows
iatandexpas dates.
Examples
HS256 token valid for one hour
Header {"alg":"HS256","typ":"JWT"}, secret a-string-secret-at-least-256-bits-long (38 bytes) and payload:
{"sub":"user-42","name":"Jane Doe","role":"admin","iat":1795262400,"exp":1795266000}iat is 21 Nov 2026 12:00 UTC and exp one hour later. The signed token:
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ1c2VyLTQyIiwibmFtZSI6IkphbmUgRG9lIiwicm9sZSI6ImFkbWluIiwiaWF0IjoxNzk1MjYyNDAwLCJleHAiOjE3OTUyNjYwMDB9.uzSuEjTrIay3BJznGZuUI5U1DJJAxcmoNGJAh9kuaR0A secret that is too short
Signing with the secret shortsecret still works, but the tool warns that it is shorter than 32 bytes, the HS256 minimum, and could be guessed by brute force.
An unsigned token
Changing the header to {"alg":"none","typ":"JWT"} gives a token with an empty third part, plus a warning that no server should ever accept it:
eyJhbGciOiJub25lIiwidHlwIjoiSldUIn0.eyJzdWIiOiJ1c2VyLTQyIn0.Common errors
- exp in milliseconds:
Date.now()returns milliseconds;exp: 1795266000000means the year 58859. Divide by 1000. - Header and payload must be JSON objects: the text is an array, a string or empty. Wrap the claims in
{ }. - "Payload:" followed by a parser message: the JSON has a syntax error, often a trailing comma or a missing quote. Check it with the JSON validator.
- Signature invalid on the server: the server uses another secret, or decodes it from Base64 while you typed it as plain text. Match the The secret is Base64URL-encoded box to how the server reads it.
FAQ
Is it safe to generate a JWT online?
Here the signing runs in your browser and keys stay in the page. Still, use test secrets: never paste a production signing key into a tool you do not control.
HS256 or RS256?
HS256 uses one shared secret to sign and verify, so every verifier could also issue tokens. RS256 and ES256 sign with a private key and verify with a public one, which suits tokens checked by many services.
Is the payload encrypted?
No. A JWT is signed, not encrypted: anyone can read it with a Base64 decoder. Never put passwords or personal secrets in claims.
How to create a JWT in code
All four snippets print the same token for the same claims:
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ1c2VyLTQyIiwiaWF0IjoxNzk1MjYyNDAwLCJleHAiOjE3OTUyNjYwMDB9.-163tTrDVxNnBrewjsuX8q_OKGc5p9osz5_gViP03oEJavaScript
With the jose library:
import { SignJWT } from 'jose';
const secret = new TextEncoder().encode('a-string-secret-at-least-256-bits-long');
const token = await new SignJWT({ sub: 'user-42' })
.setProtectedHeader({ alg: 'HS256', typ: 'JWT' })
.setIssuedAt(1795262400)
.setExpirationTime(1795266000)
.sign(secret);Python
Standard library only:
import base64, hashlib, hmac, json
def b64u(data: bytes) -> str:
return base64.urlsafe_b64encode(data).rstrip(b"=").decode()
header = {"alg": "HS256", "typ": "JWT"}
payload = {"sub": "user-42", "iat": 1795262400, "exp": 1795266000}
signing_input = b64u(json.dumps(header, separators=(",", ":")).encode()) + "." + b64u(json.dumps(payload, separators=(",", ":")).encode())
sig = hmac.new(b"a-string-secret-at-least-256-bits-long", signing_input.encode(), hashlib.sha256).digest()
token = signing_input + "." + b64u(sig)Go
enc := base64.RawURLEncoding
input := enc.EncodeToString([]byte(`{"alg":"HS256","typ":"JWT"}`)) + "." +
enc.EncodeToString([]byte(`{"sub":"user-42","iat":1795262400,"exp":1795266000}`))
mac := hmac.New(sha256.New, []byte("a-string-secret-at-least-256-bits-long"))
mac.Write([]byte(input))
token := input + "." + enc.EncodeToString(mac.Sum(nil))Bash
b64u() { openssl base64 -A | tr '+/' '-_' | tr -d '='; }
h=$(printf '%s' '{"alg":"HS256","typ":"JWT"}' | b64u)
p=$(printf '%s' '{"sub":"user-42","iat":1795262400,"exp":1795266000}' | b64u)
s=$(printf '%s' "$h.$p" | openssl dgst -sha256 -hmac 'a-string-secret-at-least-256-bits-long' -binary | b64u)
echo "$h.$p.$s"