Developer Tools

What to Put in a JWT Payload, and What to Leave Out

By Raja JahangirPublished November 29, 20265 min read
Infographic: a laptop beside Header, Payload and Signature blocks with an open padlock above the payload, a card of claims to keep in the token, and four numbered checks before shipping

Key takeaways

  • A signed JWT is encoded, not encrypted, so anyone who gets the token can read every claim in the payload without knowing the signing secret.
  • Keep access tokens small: a user ID in sub, a role or scope, and the exp, iat, iss and aud claims the API needs to check.
  • Emails, names, phone numbers, passwords and API keys do not belong in a token; they leak with it and go stale until it expires.
  • Decode one of your own test tokens before shipping and read each claim as a stranger would, then delete anything the API does not need.

Put only what the server needs to make a decision and what you would be fine with anyone reading: a user ID, a role or scope, and the time claims. Leave out emails, names, phone numbers, passwords, API keys and anything you would not print on a postcard. A signed JWT is encoded, not encrypted, so anyone who gets the token can read every claim in it in a few seconds, without the secret.

This guide shows that with a real token, explains which claims belong in an access token, and gives a short checklist for deciding what to keep in the database instead.

Anyone with the token can read the payload

A JWT is three parts joined by dots: a header, a payload and a signature. The header and payload are JSON that has been Base64URL-encoded. That is a way of writing bytes as URL-safe text, not a lock. The signature proves the first two parts were not changed after the server signed them. It does nothing to hide them.

Here is a test token signed with a throwaway secret:

eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ1c2VyXzEwNDIiLCJuYW1lIjoiU2FtIExlZSIsImVtYWlsIjoic2FtQGV4YW1wbGUuY29tIiwicm9sZSI6ImVkaXRvciIsImlhdCI6MTc2NDU0NzIwMCwiZXhwIjoxNzY3MjI1NjAwfQ.Rwv4NoMiET1uwE6sCKTPbmiDbp88PJBtUBFS2nJFedM

Paste it into the free JWT decoder and click Decode JWT. No secret is asked for, and this is what comes back:

Header
{ "alg": "HS256", "typ": "JWT" }

Payload
{
  "sub": "user_1042",
  "name": "Sam Lee",
  "email": "sam@example.com",
  "role": "editor",
  "iat": 1764547200,
  "exp": 1767225600
}

The tool also shows a red "Token is expired" banner, because the exp claim is 1 January 2026, 00:00 UTC (it prints the date in your local time). The name and the email address are sitting there in plain sight. Anyone who sees this token in a browser's local storage, a log file, a proxy, a screenshot or a support ticket can read them the same way.

You can confirm it is only encoding by pasting the middle part into the Base64 decoder: the same JSON comes out. Our guide on why Base64 is encoding, not encryption explains the difference in more detail.

Table with Claim and In the token? columns marking user ID, role and time claims Yes, email and full name Usually no, and passwords and API keys Never, next to a photo of hands typing on a laptop

What belongs in an access token

An access token is a short-lived pass. The API that receives it should be able to answer two questions from the token alone: who is this, and are they allowed to do this? Everything else can be looked up.

Claim Keep it? Why
sub (user ID) Yes An opaque ID such as user_1042 says who the token is for without revealing anything about the person
role or scope Yes The API needs it to allow or refuse the request
exp, iat, nbf Yes Expiry and issue times limit how long a leaked token works
iss, aud Yes Tell the API which server issued the token and who it is for
email, full name Usually no Personal data that does not change what the API is allowed to do
phone, address, date of birth No Personal data with no use in an authorization check
password or password hash Never Readable by anyone holding the token
API keys, internal secrets Never Same reason; one leaked token leaks the key too

The registered claim names sub, iss, aud, exp, nbf, iat and jti come from the JWT standard, RFC 7519. None of them are required, but using them means libraries know how to check them for you.

Why people put user data in tokens anyway

The usual reason is to save a database lookup: if the name and email are in the token, the front end can show "Signed in as Sam Lee" straight away. That works, but it has costs beyond privacy.

  1. The data goes stale. If the user changes their email, every token issued before the change keeps the old one until it expires.
  2. Tokens get bigger. Every claim is sent on every request in the Authorization header. A token stuffed with profile data adds bytes to each call.
  3. Roles in the token are a snapshot. If you remove someone's admin role, their current token still says admin until exp. Keep access tokens short-lived (minutes, not days) so changes take effect quickly.

A cleaner pattern is to keep the access token small and fetch the profile once from a /me endpoint after sign-in. If you use OpenID Connect, the ID token is meant for the client to read and can carry profile claims, but it should not be sent to your APIs as an access token.

If the data really must travel in the token

Some systems need claims that should not be readable by the client. In that case, encrypt the token rather than only signing it. The JOSE standards define JWE (JSON Web Encryption) for this. An encrypted token cannot be read by pasting it into a decoder. A JWE in compact form has five dot-separated parts instead of three, and our decoder refuses it with the message "Invalid JWT: must have 3 parts".

Encryption adds key management and complexity, so most apps are better off simply not putting the sensitive field in the token.

A quick checklist before you ship

  1. Decode one of your real test tokens with the JWT decoder and read every claim as if you were a stranger.
  2. Delete any claim that is personal data and not needed for an access decision.
  3. Check exp: convert it with the timestamp converter and make sure the lifetime is what you intended.
  4. Check the header's alg is the algorithm your server expects, and that your server verifies the signature on every request. Decoding is not verifying.
  5. Never paste live production tokens into any online tool. A valid token works like a password until it expires; use a test or expired token.

Sources

Frequently asked questions