JWT Encoder
Create and sign HS256 JSON Web Tokens with custom payload and secret key.
Client-Side Execution & Privacy Guarantee
This utility executes 100% locally in your web browser. Your inputs, tokens, queries, and data payloads are never transmitted to any external server or backend.
JSON Web Tokens (JWTs) are compact, URL-safe claims that can be verified with a signature. The JWT Encoder produces HS256 tokens by taking a JSON header (normally the fixed {"alg":"HS256","typ":"JWT"}), a JSON payload of claims, and a shared secret. It Base64url-encodes the header and payload, joins them with a period, and computes an HMAC-SHA256 signature over that string using the secret you supply.
The entire operation stays inside the browser. No token or secret is sent anywhere. The result is a three-segment string ready for use in Authorization headers, unit tests, or local API exploration. Because HS256 is a symmetric algorithm, anyone who possesses the secret can both create and verify tokens; treat the secret accordingly and never embed production secrets in client-side code.
Header, payload, and the three segments
A JWT consists of three Base64url-encoded parts separated by dots. The first part is the header, which declares the algorithm and token type. The second is the payload, an object of claims such as sub, name, iat, or exp. The third is the signature. The encoder constructs the first two segments from the JSON you provide, then signs the concatenation of those two segments.
Base64url differs from ordinary Base64 by using - and _ instead of + and / and by omitting padding. The tool handles this conversion automatically so the token remains valid in URLs and HTTP headers.
HS256 signature construction
HS256 means HMAC with SHA-256. The encoder takes the secret as a byte string, feeds the header-payload string into the HMAC-SHA256 function, and Base64url-encodes the resulting digest. Changing a single character in the payload or using a different secret produces a completely different signature, which is how recipients detect tampering.
The tool does not implement other algorithms such as RS256 or ES256. If you need asymmetric signatures you must generate those elsewhere; the companion inspector can still decode any JWT header and payload regardless of algorithm.
Registered claims and practical limits
The payload may contain any JSON values, but registered claims have conventional meanings: iss (issuer), sub (subject), aud (audience), exp (expiration as NumericDate), nbf (not-before), iat (issued-at), and jti (JWT ID). The encoder does not enforce these semantics; it simply serializes whatever object you supply.
Keep payloads small. Tokens are often placed in headers or cookies, and large claims increase request size and latency. Also remember that the payload is only Base64url-encoded, not encrypted, so never put sensitive data in it unless the transport is already protected and the audience is trusted.
When to use this tool
- Generating sample tokens for unit tests or Postman collections
- Exploring how claim changes affect the signature
- Creating short-lived tokens for local development against an API that expects HS256
- Teaching or documenting the structure of a JWT
- Verifying that a secret and payload pair produce the expected token before integrating a library
How to use the JWT Encoder
- Enter or paste a JSON object for the header; leave the default if you only need HS256.
- Enter the payload as a JSON object containing the claims you want.
- Type the secret key into the secret field (it is never stored).
- Click Generate. The tool immediately displays the complete token.
- Copy the token or examine its three segments separately.
- Optionally paste the same token into the JWT Inspector to confirm the signature matches.
- Clear the fields when finished so the secret does not remain in the page.
Worked examples
Standard example token
Header: {"alg":"HS256","typ":"JWT"}\nPayload: {"sub":"1234567890","name":"John Doe","iat":1516239022}\nSecret: your-256-bit-secret
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c
This is the well-known example from jwt.io. The signature matches only when the secret is exactly your-256-bit-secret.
Minimal claims with custom secret
Header: {"alg":"HS256","typ":"JWT"}\nPayload: {"user":"ada"}\nSecret: s3cr3t
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjoiYWRhIn0.4N-JdKqewQB2Hjfg2fSvCYby_G4bqpgqpd24SldC38Y
Short payload. Signature will differ if the secret or any claim changes. Verify locally with the inspector.
Common mistakes and tips
- Never use a production secret in the browser; the encoder is for development and education only.
- Ensure the payload is valid JSON before generating; trailing commas or single quotes will cause failure.
- NumericDate claims (exp, iat, nbf) are seconds since the Unix epoch; use the timestamp tool if you need to convert.
- If the generated token fails verification elsewhere, compare the exact secret bytes and confirm the header algorithm is HS256.
- For very long secrets the HMAC still works, but keep them reasonable; the tool accepts any string.
Frequently asked questions
Why does the tool only support HS256?
HS256 is the most common symmetric algorithm and can be implemented entirely with browser Web Crypto APIs. Asymmetric algorithms require private keys that are rarely available in a pure browser tool.
Is the payload encrypted?
No. JWT payloads are only Base64url-encoded. Anyone can decode them. Use JWE if you need confidentiality.
Can I include nested objects or arrays in the payload?
Yes. Any valid JSON value is accepted and will appear correctly in the decoded token.
What happens if the secret contains special characters?
The secret is treated as a UTF-8 string. Special characters are fine; just make sure the verifying side uses the identical byte sequence.
Does the encoder set an expiration automatically?
No. You must include an exp claim yourself if you want one. The tool does not add claims.