# 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.

Source: https://fullbytedeveloper.com/blog/jwt-peek
Published here: 2026-11-20, updated 2026-12-03

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].

```python
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())
```

```bash
python3 decode_jwt.py
```

Captured output:

```text
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.

<figure>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 720 260" role="img" aria-label="Compact JWS: header and payload decode without a key; signature needs the signer key">
  <defs>
    <marker id="arrowJwtPeek" markerWidth="10" markerHeight="10" refX="8" refY="3" orient="auto">
      <path d="M0,0 L8,3 L0,6 Z" fill="#14b8a6"/>
    </marker>
  </defs>
  <rect x="0" y="0" width="720" height="260" rx="12" fill="#0b1f3a"/>
  <text x="24" y="36" fill="#f8fafc" font-family="ui-sans-serif, system-ui, sans-serif" font-size="16" font-weight="700">compact JWT (JWS) [1][3]</text>
  <rect x="24" y="52" width="170" height="72" rx="8" fill="#123052" stroke="#14b8a6" stroke-width="2"/>
  <text x="36" y="80" fill="#14b8a6" font-family="ui-sans-serif, system-ui, sans-serif" font-size="14">header</text>
  <text x="36" y="104" fill="#cbd5e1" font-family="ui-monospace, monospace" font-size="14">alg, typ (readable)</text>
  <text x="206" y="92" fill="#f8fafc" font-family="ui-monospace, monospace" font-size="18">.</text>
  <rect x="220" y="52" width="190" height="72" rx="8" fill="#123052" stroke="#14b8a6" stroke-width="2"/>
  <text x="232" y="80" fill="#14b8a6" font-family="ui-sans-serif, system-ui, sans-serif" font-size="14">payload</text>
  <text x="232" y="104" fill="#cbd5e1" font-family="ui-sans-serif, system-ui, sans-serif" font-size="14">claims (readable)</text>
  <text x="418" y="92" fill="#f8fafc" font-family="ui-monospace, monospace" font-size="18">.</text>
  <rect x="432" y="52" width="264" height="72" rx="8" fill="#123052" stroke="#f59e0b" stroke-width="2"/>
  <text x="444" y="80" fill="#f59e0b" font-family="ui-sans-serif, system-ui, sans-serif" font-size="14">signature</text>
  <text x="444" y="104" fill="#cbd5e1" font-family="ui-sans-serif, system-ui, sans-serif" font-size="14">integrity only (needs key to mint)</text>
  <path d="M120 124 V152" stroke="#14b8a6" stroke-width="3" fill="none" marker-end="url(#arrowJwtPeek)"/>
  <path d="M120 152 H315" stroke="#14b8a6" stroke-width="3" fill="none" marker-end="url(#arrowJwtPeek)"/>
  <rect x="24" y="168" width="320" height="72" rx="8" fill="#123052" stroke="#64748b" stroke-width="2"/>
  <text x="36" y="196" fill="#f8fafc" font-family="ui-sans-serif, system-ui, sans-serif" font-size="14">decode header + payload</text>
  <text x="36" y="220" fill="#cbd5e1" font-family="ui-sans-serif, system-ui, sans-serif" font-size="14">no key; possession = read access</text>
  <path d="M564 124 V152" stroke="#14b8a6" stroke-width="3" fill="none" marker-end="url(#arrowJwtPeek)"/>
  <path d="M564 152 H460" stroke="#14b8a6" stroke-width="3" fill="none" marker-end="url(#arrowJwtPeek)"/>
  <rect x="360" y="168" width="336" height="72" rx="8" fill="#123052" stroke="#f59e0b" stroke-width="2"/>
  <text x="372" y="196" fill="#f8fafc" font-family="ui-sans-serif, system-ui, sans-serif" font-size="14">verify signature</text>
  <text x="372" y="220" fill="#cbd5e1" font-family="ui-sans-serif, system-ui, sans-serif" font-size="14">confidential payload needs JWE (5 parts) [2]</text>
</svg>
</figure>

*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

1. PII in claims because the token is signed. Signature is not encryption [1][3].
2. Homemade verifiers that accept `alg=none` or algorithm confusion. Use a maintained library and pin allowed algorithms [3].
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.
4. 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

1. Decode a staging token once with the script above and list every claim.
2. Delete any claim that is not required for the request path.
3. Move secrets and sensitive PII to server-side session or encrypted storage.
4. If confidentiality on the token itself is required, implement JWE per RFC 7516 and verify five-part compact form [2].
5. 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:

```bash
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; echo
```

On 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 `role` to `admin` and 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](/blog/math-random-not-secure-tokens).

Send this to the friend who stuffs emails and roles into a JWT because it looked encrypted.

Image: Three linked token segments on a dark grid: two translucent teal glass chambers with abstract inner waves, the middle chamber opened on a hinge for inspection, and a solid amber signature seal on the end, with no letters, words, or typography.
https://fullbytedeveloper.com/media/jwt-peek/jwt-peek-venice.webp
The first two parts are readable. A signature is not the same thing as encryption.

## Sources

1. [RFC 7519: JSON Web Token (JWT)](https://www.rfc-editor.org/rfc/rfc7519)
2. [RFC 7516: JSON Web Encryption (JWE)](https://www.rfc-editor.org/rfc/rfc7516)
3. [RFC 7515: JSON Web Signature (JWS)](https://www.rfc-editor.org/rfc/rfc7515)
