JWTs are signed, not encrypted - anyone can read them
A JWT is base64 data dot base64 data dot signature. The first two parts are plain text.
Published here , updated · 3 sources · Resume reading
A compact JWT is three base64url segments joined by dots: header, payload, signature [1][3]. The first two segments are encoded JSON, not ciphertext. Anyone who holds the token can decode them with no key. The third segment proves integrity when you verify with the right key; it does not hide the claims.
Decode a token in one minute
JWT omits padding on base64url, so pad before decoding [1].
import base64
token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIn0.dozjgNryP4J3jVmNHl0w5N_XgL0n3I9PlFUP0THsR8U"
parts = token.split(".")
print("parts:", len(parts))
for i, name in enumerate(("header", "payload")):
s = parts[i] + "=" * (-len(parts[i]) % 4)
print(name + ":", base64.urlsafe_b64decode(s).decode())python3 decode_jwt.pyCaptured output:
parts: 3
header: {"alg":"HS256","typ":"JWT"}
payload: {"sub":"1234567890"}Three parts means JWS compact serialization (signed JWT) [1][3]. Five parts point at compact JWE instead [2].
What each segment is for
Header names the algorithm and token type (alg, typ) [1].
Payload holds claims: registered ones like sub, iat, exp, plus whatever your app added [1]. Those claims are application data in cleartext encoding.
Signature is computed over the header and payload encodings with the header algorithm [3]. Verification recomputes and compares. Reading never needs the key. Forging a new payload without the key should fail verification.
Teal segments are public JSON once encoded; the amber signature binds bytes but does not encrypt them.
What shows up in real payloads
Typical claims after decode:
sub: subject, often a user id [1]iat/exp: issued-at and expiry as NumericDate [1]- custom claims:
role, plan flags, email, internal ids
If role is admin, a stolen token shows that claim in plain decode. If you put a government id or raw secret in the payload, the thief reads it the same way the script did. Signature verification still matters for authenticity; it does not create confidentiality [1][3].
Encryption is a different token: JWE
When the payload must stay confidential for holders without the decryption key, RFC 7516 defines JSON Web Encryption [2]. Compact JWE serialization uses five segments. Counting dots is a quick smell test: two dots (three parts) is JWS/JWT style; four dots (five parts) is compact JWE [1][2].
Do not rename a signed JWT encrypted in an architecture doc because the library folder is called crypto. Check the wire format and the RFC you implemented.
Library pitfalls that leak or break verify
- PII in claims because the token is signed. Signature is not encryption [1][3].
- Homemade verifiers that accept
alg=noneor algorithm confusion. Use a maintained library and pin allowed algorithms [3]. - Decode-without-verify used as authorization. Decode is fine for debugging a token you already trust from a verified path; authorization belongs after signature and claim checks succeed.
- Full tokens in CI logs or browser analytics. Anyone with log access can read the payload the same way the script did.
A small hygiene checklist
- Decode a staging token once with the script above and list every claim.
- Delete any claim that is not required for the request path.
- Move secrets and sensitive PII to server-side session or encrypted storage.
- If confidentiality on the token itself is required, implement JWE per RFC 7516 and verify five-part compact form [2].
- Keep verification key material out of the JWT.
Why this keeps biting API designs
Mobile and SPA teams stuff profile fields into access tokens to avoid an extra /me round trip. That trade looks cheap until a token leaks through a browser extension, a crash report, or a support screenshot. The attacker does not need your signing key to harvest those fields; they only need the string [1].
Refresh tokens and server sessions exist so the short-lived access token can stay small. Keep identity facts that change often (plan tier, email) behind an authenticated API after verify, not inside every bearer string.
Bash peek without a Python file
If you only need a quick look at one staging token in a shell:
TOKEN='eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIn0.dozjgNryP4J3jVmNHl0w5N_XgL0n3I9PlFUP0THsR8U'
payload=$(printf '%s' "$TOKEN" | cut -d. -f2)
pad=$(( (4 - ${#payload} % 4) % 4 ))
printf '%s' "$payload$(printf '=%.0s' $(seq 1 $pad))" | tr '_-' '/+' | base64 -d; echoOn a machine with GNU base64 that printed {"sub":"1234567890"}. macOS base64 flags differ; if the one-liner fights you, use the Python snippet instead. Either way, you never sent the token to a website.
What "signed, not encrypted" means for theft
Steal a bearer JWT from a proxy log and you can read every claim immediately. You still cannot mint a new valid signature without the key under normal JWS verification [1][3]. Those are different threats:
- Confidentiality failure: email, role, and internal ids were in the payload.
- Integrity failure: someone changed
roletoadminand your verifier still accepted the token (broken verify,alg=none, or key leak).
Fixing integrity (verify correctly, pin alg, protect keys) does not fix confidentiality. If the claim should stay secret from the bearer, it does not belong in a JWS payload [1][2].
Operational habits that reduce blast radius
Prefer opaque session ids for browser clients when the server already has a session store. If you must use JWTs for service-to-service calls, keep claims minimal, set short exp, rotate keys, and monitor decode failures after rotations [1].
Never paste production tokens into third-party "jwt debugger" websites. Use the local Python decode on this page instead. Possession equals readability.
JWS versus "JWT" in conversation
Engineers say JWT when they mean a signed compact JWS with JSON claims [1][3]. That shorthand is fine until someone hears "token" and pictures ciphertext. In design reviews, say "signed JWT (JWS)" or "encrypted token (JWE)" out loud once. The extra four words prevent a class of security bugs.
Claims that age badly inside a token
Even non-secret claims become a problem when they go stale. Put plan: pro in a 24-hour access token and a user who downgrades still looks Pro to every service that trusts the claim without a server check. The signature is still valid; the business fact is wrong. Prefer a stable subject id (sub) in the JWT and load plan, email, and roles from your own store after verify [1].
The same pattern shows up with permission lists. A long scopes array copied into every token makes revocation harder: you wait for exp or maintain a denylist. Short TTL plus a central session or token version check is the usual trade when you need faster cut-off than expiry alone.
Related reading on weak token generators: Math.random is the wrong tool for reset tokens.
Send this to the friend who stuffs emails and roles into a JWT because it looked encrypted.

Keep this guide
Filed under Security
Questions about this guide
Can someone tamper with my JWT?
They can read and decode the header and payload, but changing those bytes without the signing key invalidates the signature under normal verification.
How do I encrypt a JWT?
Use JWE (RFC 7516). A compact JWE has five base64url segments separated by dots, not three.
Is base64 encoding encryption?
No. Base64url is an encoding so binary can travel as text. Anyone can decode it without a key.
Sources
- RFC 7519: JSON Web Token (JWT)rfc-editor.org
- RFC 7516: JSON Web Encryption (JWE)rfc-editor.org
- RFC 7515: JSON Web Signature (JWS)rfc-editor.org