JWT Decoder & Generator · TokenSmith

Decode and generate JWTs, with HMAC signature verification.

Updated:

100% client-side

JWT Token

Paste a token to decode it.

Header


          

Payload


          

Data

Generated token

—
—

What is a JWT?

A JWT (JSON Web Token, RFC 7519) is a compact, signed piece of text that web apps use to prove who a user is without checking a database on every request — it's what's usually stored after you log in to keep you authenticated. It's not encrypted, just signed: anyone can read what's inside, but only someone with the secret key can have created a valid signature. TokenSmith lets you inspect one, or build your own for testing.

How to use the JWT decoder & generator

  1. To inspect a token, stay on the Decode tab and paste it into the JWT Token box (or click Example to try a sample).
  2. The Header and Payload panels show the decoded contents instantly.
  3. Optionally enter the shared secret in the "Secret" field to verify the HMAC signature is valid.
  4. To build a token instead, switch to the Generate tab, pick an algorithm, write your payload as JSON and a secret.
  5. Click Copy to grab the generated token.

How a JWT works

A JSON Web Token has three parts separated by dots: header.payload.signature, each Base64URL-encoded per the compact serialization defined in RFC 7515 (JWS). The header describes the algorithm (per RFC 7518, which defines HS256/HS384/HS512), the payload carries the data (claims), and the signature guarantees nobody altered the content without knowing the secret:

For a real token taken apart, the registered claims and the mistakes that become security bugs, read the guide How a JWT Works: Decoding a Real Token.

eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxMjMifQ.4kP...
└── header ──────────┘└── payload ───────┘└ sig ┘

This tool decodes with the browser's native atob and JSON.parse, and signs/verifies with native crypto.subtle (HMAC-SHA) — no external libraries, no server calls.

Examples

1. Sign a token with HS256. In Generate mode, this payload signed with the secret change-me always produces the same token — HMAC signatures are deterministic, so you can reproduce it with any JWT library to check your own code:

Payload: {"sub": "42", "role": "admin", "exp": 1767225600}
Secret:  change-me

eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI0MiIsInJvbGUiOiJhZG1pbiIsImV4cCI6MTc2NzIyNTYwMH0.xO-iqf_ksQQZ1aKB-SXXPeyfNv9EsVeT1ywZ-YBikUE
(140 characters · signed with HS256)

2. Decode it and verify the signature. Paste that token in Decode mode: the header and payload appear as formatted JSON, and typing change-me in the secret field shows Valid signature (HS256). Any other secret shows Invalid signature — doesn't match the entered secret.

Header:  {"alg": "HS256", "typ": "JWT"}
Payload: {"sub": "42", "role": "admin", "exp": 1767225600}
Claims:  exp → 2026-01-01 00:00 UTC (shown in your local time) · Expired

3. Spot an unsigned token. A token whose header says "alg": "none" and whose third part is empty carries no signature at all. The decoder reads it and tells you plainly that it can't be verified — a token like this should be rejected by any server:

eyJhbGciOiJub25lIiwidHlwIjoiSldUIn0.eyJzdWIiOiI0MiIsInJvbGUiOiJhZG1pbiIsImV4cCI6MTc2NzIyNTYwMH0.
→ Algorithm "none" is not HMAC — the signature can't be verified here.

Common JWT errors and how to fix them

  • Expired token (exp). exp, iat and nbf are seconds since 1970 in UTC, not milliseconds. A token "that expires immediately" was often built with Date.now() (milliseconds) divided incorrectly — or not divided at all, giving a date thousands of years away. The claims panel converts each one to a readable date and flags expired tokens. To convert other timestamps, use the Unix Timestamp Converter.
  • Decoding is not verifying. Anyone can read a JWT's payload; the signature is what proves it wasn't changed. Your server must verify the signature with the expected key and algorithm before trusting any claim — never just decode and use it.
  • Accepting alg: none or switching algorithms. Libraries that read the algorithm from the token itself have historically accepted unsigned tokens or confused HMAC with RSA keys. Pin the allowed algorithm on the server, as recommended in RFC 8725 (JWT Best Current Practices).
  • Base64url vs. Base64. JWT segments use the URL-safe alphabet (- and _, no = padding). Decoding them with a standard Base64 function fails or returns garbage. The Base64 decoder accepts both alphabets if you need to inspect a single segment.
  • Malformed token. A JWT has exactly three dot-separated parts; abc.def is rejected with A JWT must have 3 parts separated by dots. Check that the copied value doesn't include the Bearer prefix or got cut off.
  • Invalid JSON in the payload. Generate mode refuses to sign a payload such as {"sub": "42",} and reports where the JSON breaks, so you never ship a token your own server can't parse.

JWT decoder vs. the command line

For a quick look without a browser, the payload is the second segment: echo 'PAYLOAD' | base64 -d works once you swap -/_ for +// and add = padding, which is exactly the step that trips people up. Verifying the signature from a shell needs openssl dgst -sha256 -hmac 'change-me' -binary plus a Base64url conversion. This page does both in one step and shows the claims as dates. For signatures other than HMAC (RS256, ES256) verify in your backend with your JWT library and the public key. To compute a raw HMAC over any message, use the HMAC Generator.

Frequently asked questions

Which signing algorithms can it verify?

HS256, HS384 and HS512 (HMAC with a shared secret). For asymmetric algorithms like RS256 or ES256 the content is decoded, but the signature can't be verified without the matching public key.

Is my secret or token sent to any server?

No. Verification and generation use the browser's native SubtleCrypto API; the secret never leaves your machine.

What are 'exp', 'iat' and 'nbf' in the payload?

RFC 7519's registered claims, in Unix seconds: 'iat' is when the token was issued, 'exp' when it expires, 'nbf' from when it's valid. This tool also shows them as a readable date.

Can I generate a signed JWT from scratch?

Yes, on the Generate tab: pick the HMAC algorithm, write the payload as JSON and a secret, and the tool builds and signs the full token.