Quick access

Saved in this browser. Sign in to keep it on all your devices.

JWT Encoder

Create and encode JWT tokens with custom payload.

Payload (JSON)

Enter the claims you want in the token payload.

Quick Claims

Version 1.1 Updated What's new

Release notes

  1. v1.1 Latest
    • Added an in-depth guide below the tool, written from what the tool actually does.
    • Tokens are signed with HS256, HS384 or HS512, and the secret is never saved.

About the JWT Encoder

The JWT encoder builds and signs a JSON Web Token from a header, a payload of claims, and a secret key, which is handy for testing APIs and authentication.

How to use it

  1. 1 Edit the payload claims, such as sub and exp.
  2. 2 Choose an algorithm and enter a secret.
  3. 3 Copy the signed token.

Frequently asked questions

Which algorithm should I use?

HS256 is the most common shared-secret algorithm. Use a long, random secret of at least 32 characters.

Should I put sensitive data in a JWT?

No. The payload is only encoded, not encrypted, so anyone holding the token can read it.

Should I use tokens made here in production?

Use this tool for testing. Production tokens should be created by your server, with secrets that never leave it.

Three parts joined by dots

A JSON Web Token is written as header.payload.signature. The header states the algorithm, the payload holds the claims, and each is converted to Base64URL, a version of Base64 that uses - and _ and drops the = padding so the token is safe in a URL. The signature is computed like this:

HMAC-SHA256(
  base64url(header) + "." + base64url(payload),
  secret
)

Signing happens in your browser with the Web Crypto API. The secret is not sent to our server or saved between visits. The resulting token can be checked with any standard JWT library or with the JWT Verifier on this site.

Registered claims worth knowing

RFC 7519 reserves a handful of short names. All are optional, and your application decides which it requires:

  • iss names who issued the token, and aud names who it is intended for.
  • sub identifies the subject, usually a user ID.
  • exp is the expiry time, nbf is the time it becomes valid, and iat records when it was issued.
  • jti gives the token a unique ID, which helps when you need to block one.

The three time claims are in seconds since 1970. JavaScript’s Date.now() returns milliseconds, and using it directly sets an expiry tens of thousands of years away, a mistake that is easy to miss because the token keeps working. The Expiration menu here writes seconds for you.

Signed does not mean secret

Anyone holding a token can decode its payload without the key. The signature only proves the content has not been changed since it was signed. Keep passwords, card numbers and personal details out of the claims. If the contents must be hidden, the separate JWE standard covers encrypted tokens.

How long the secret should be

RFC 7518 requires an HMAC key at least as long as the hash output: 256 bits for HS256, 384 for HS384 and 512 for HS512. A short memorable phrase can be guessed offline, because an attacker with one token can try millions of secrets against it without contacting your server. The Generate Secret button produces 256 random bits, which suits HS256. Use a longer key for the other two.

Shared secrets and their limits

The HS algorithms use one key for both signing and verifying, so any service that can check a token can also create one. When several independent services need to verify tokens, asymmetric algorithms such as RS256 or ES256 are a better fit, since only the issuer holds the private key. This encoder covers the HMAC family only.

Use tokens made here for testing, and never paste a production secret into a web page, even one that works locally like this.