Skip to main content
Toolsjwt-decoder8 min read

Decoding a JWT is not verifying it: what each step proves

A forged JWT decodes as cleanly as a real one. The six checks a server must run, what RFC 8725 says about alg none, and what signature length reveals.

Published

Cover banner: Decoding a JWT is not verifying it: what each step proves, with the free JWT Decoder

Decoding a JWT only reverses its Base64url encoding, so anyone holding the token can read the header and claims without a key. Verifying is different: the server recomputes the signature with a trusted key and an allowed algorithm, then checks expiry, issuer and audience. A token that decodes cleanly can still be forged, expired or meant for another service.

This guide builds a sample token, decodes it, tampers with it, and shows exactly why a decoder cannot tell the difference. The examples were produced with the code behind AltFTool's JWT decoder and Base64 URL encoder, and the rules come from the IETF standards that define JWTs.

What decoding actually does

A signed JWT is three Base64url strings joined by dots: header.payload.signature. Base64url is the URL-safe Base64 alphabet from RFC 4648, which uses - and _; the JWS standard, RFC 7515, also has it drop the = padding. It is an encoding, not encryption, so decoding needs no secret at all.

Encoding the header {"alg":"HS256","typ":"JWT"} gives eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9, which is why so many tokens start with eyJ: that is how {" encodes when a letter follows it, as it does in a compact JWT header. A sample payload with a subject, a name, a role of viewer, an iat and an exp one hour later encodes to 108 characters. Paste the assembled token into the decoder and it shows every claim in plain JSON.

That readability is by design. RFC 7519's privacy section says a JWT may contain privacy-sensitive information and that measures must be taken to prevent disclosure, for example encrypting the token or only sending it over TLS. Its simplest advice is to leave sensitive information out. If you would not print a value on a postcard, do not put it in a signed-but-unencrypted JWT payload.

A tampered token decodes just as cleanly

Now change one claim. Re-encode the same payload with role set to admin, keep the original header and signature, and paste it into the decoder. It decodes perfectly and reports no warnings: the header still says HS256, the JSON is valid, and the role now reads admin.

A decoder has no way to notice, because it never touches the signature's maths. Only a party holding the right key can recompute the signature over header.payload and see that it no longer matches. This is exactly the point RFC 7519 makes in its "Trust Decisions" section: the contents of a JWT cannot be relied upon for a trust decision unless they have been cryptographically secured and bound to the context of that decision.

What you seeDecoder saysWhat it really means
Original tokenDecodes, no warningsReadable; authenticity unknown until verified
Same token, role changed to adminDecodes, no warningsForged; signature check would fail
Header alg set to noneDecodes, warns "unsigned"Anyone could have made it; servers must reject it
Only two parts (no signature)Decodes, warns it can't be verifiedNo integrity protection at all
Five partsRefuses to decode the payloadAn encrypted JWE; needs the decryption key
Behaviour of the JWT decoder's decodeJwt function, run on 13 November 2026.
JWT Decoder

Read a token's header and claims locally in your browser, with warnings for alg none and missing signatures.

Open JWT Decoder

The steps a server performs to verify a token

RFC 7519 section 7.2 lists the validation steps and says the token must be rejected if any of them fails. The IETF's JWT best-practice document, RFC 8725, adds the checks that real-world attacks have shown are necessary. In practice a verifier does the following, in roughly this order:

  1. Split the token on dots and reject it unless it has the expected number of parts.
  2. Decode the header and accept only an algorithm from a fixed allow-list configured on the server, never whatever the header asks for.
  3. Select the key from trusted configuration for that algorithm and issuer, not from a URL or key ID supplied unchecked in the token.
  4. Recompute the signature over the header and payload and compare it with the signature segment.
  5. Reject the token if the current time is at or after exp, or before nbf, allowing at most a few minutes of clock skew.
  6. Confirm that iss is the issuer you trust and that aud names your service.

Step 2 is where many historic vulnerabilities lived. RFC 8725 section 2.1 describes attackers changing the algorithm to none, which some libraries then "validated" without any signature, and section 3.1 requires libraries to let the caller specify the supported algorithms and to use no others. The decoder flags alg: none as a warning for this reason, but only your server's verification can actually refuse it.

Expiry and time claims are Unix seconds

The exp, nbf and iat claims are NumericDate values: seconds since 1970-01-01T00:00:00Z. In the sample token, iat is 1794528000 (00:00 UTC on 13 November 2026) and exp is 1794531600, exactly 3,600 seconds later. The decoder converts both to readable dates and states whether the token has already expired, using your device's clock. You can cross-check any value in the Unix timestamp converter.

Two cautions apply. RFC 7519 says the token must not be accepted on or after the exp time, with "some small leeway, usually no more than a few minutes" for clock skew, so a generous skew allowance quietly extends every token's life. And because the value is seconds, a library that treats it as milliseconds reads exp as a date in late January 1970 and rejects every token as expired.

Signature length hints at the algorithm

You can often tell the algorithm from the signature segment alone, because its length depends on the signature size in bytes.

algSignature bytesBase64url characters
HS2563243
HS3844864
HS512 or ES2566486
RS256 (2048-bit key)256342
Lengths computed with the Base64 URL encoder's unpadded encodedLength function.

HMAC algorithms such as HS256 use one shared secret to both sign and verify, so every service that verifies a token could also mint one. RFC 7518 requires an HS256 key of at least 256 bits, and RFC 8725 warns that human-memorable passwords must not be used as keys, because an attacker holding a single token can try guesses offline. RSA and ECDSA algorithms split the keys, so verifiers hold only a public key that cannot sign anything.

Frequently asked questions

An attacker changes the header's alg to none and strips the signature. RFC 8725 describes libraries that then accepted such tokens as valid; the defence is a server-side allow-list of algorithms that never includes none.

No. Verification means recomputing or checking the signature, which needs the shared secret for HS algorithms or the issuer's public key for RS, PS and ES algorithms.

The header is a JSON object that begins with {" followed by a letter, as in {"alg". Base64url-encoding that start produces eyJ; a header with a space after the brace would start differently.

Not by itself. RFC 7519 also requires rejecting tokens outside their exp and nbf window, and RFC 8725 asks verifiers to check the issuer and audience, so a correctly signed token for another service should still be refused.

A five-part token is an encrypted JWE: RFC 7516 says JWEs have five segments separated by four dots. Its payload is ciphertext, so no decoder can read the claims without the decryption key.

Sources and notes

Links the author listed for this post.

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6

Reader feedback

Was this guide helpful?

Your signal helps the editorial team improve stale or unclear guides faster.

Share this article

Written by

The sample tokens, decoder warnings and signature lengths in this article were produced on 13 November 2026 with the code behind AltFTool's JWT decoder (decodeJwt, claimDateMs) and Base64 URL encoder (encodeToBase64Url, encodedLength).

Your inbox, your topics

What do you want more of?

Pick the topics you'd like in your inbox. We've ticked one that matches this guide — change them freely.

Topics you want more of

Up to 200 characters.

Privacy policy

Discussion

0 comments

Loading discussion