Quick revision
The short answer
A JWT is three base64url-encoded parts separated by dots: a header with fields such as alg, typ and kid, a payload with the claims, and a signature over the first two. The registered claims mean issuer (iss), subject (sub), audience (aud), expiry time (exp), not before (nbf), issued at (iat) and a unique token id (jti). The payload of a signed JWT is not secret: it is only encoded, so anyone holding the token can read it, and confidentiality needs encryption with JWE or, more simply, keeping sensitive data out of the token.
What to remember
In this answer, we took a JWT apart. It has a header with alg, typ and kid, a payload of claims and a signature, all base64url encoded and joined by dots. The registered claims are iss for the issuer, sub for the subject, aud for the audience, exp for expiry, nbf for not before, iat for issued at and jti for a unique id. The payload of a signed JWT is readable by anyone holding it, so secrets need JWE or, better, stay out of the token, while the signature over header and payload makes any change detectable.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
A JWT is three base64url-encoded parts separated by dots: a header with fields such as alg, typ and kid, a payload with the claims, and a signature over the first two. The registered claims mean issuer (iss), subject (sub), audience (aud), expiry time (exp), not before (nbf), issued at (iat) and a unique token id (jti). The payload of a signed JWT is not secret: it is only encoded, so anyone holding the token can read it, and confidentiality needs encryption with JWE or, more simply, keeping sensitive data out of the token.
Why this question is asked
JWTs are everywhere in Spring systems, as access tokens, ID tokens and service-to-service credentials, and many people treat them as opaque magic strings. Interviewers ask about the structure because the details explain real decisions: why tokens leak data, why expiry checks need clock skew, and why changing one character breaks the signature. In this answer, we will take a token apart, explain each registered claim with an example, show that the payload is readable by anyone, and see what the signature does and does not protect.
1The Three Parts of a JWT
A JWT, JSON Web Token, looks like a long string with two dots in it. Each part is JSON or bytes encoded with base64url, a variant of base64 that uses - and _ instead of + and / and drops the = padding, so the token is safe in URLs and HTTP headers.
| Part | Contains | Protected by signature? |
|---|---|---|
| Header | alg, typ, kid | yes |
| Payload | claims: iss, sub, aud, exp, roles ... | yes |
| Signature | issuer's signature over header.payload | it is the protection |
The header describes how the token is protected. alg names the signing algorithm, here RS256, RSA with SHA-256. typ says what kind of token it is, often JWT or, for access tokens, at+jwt. kid, the key id, tells the verifier which of the issuer's keys was used, which matters when the issuer has several during a key rotation.
The payload holds the claims, the statements the token makes. The signature is computed by the issuer over the encoded header, a dot, and the encoded payload.
2The Registered Claims
RFC 7519 registers a small set of claim names so that every system means the same thing by them. Here is a payload that uses all of them.
iss lets a resource server check that the token comes from the provider it trusts. sub identifies the user or, for machine tokens, the client; it is unique within the issuer, so the pair iss and sub identifies a principal. aud names the intended recipients, so a token minted for orders-api is not accepted by billing-api.
The three time claims are numbers of seconds since 1 January 1970 UTC. exp is the most important: after it, the token is dead. nbf says when the token starts to be valid, and iat records when it was issued, which helps to spot tokens issued before an event such as a password change. Because servers' clocks drift a little, verifiers allow a small clock skew, 60 seconds by default in Spring Security, when checking exp and nbf.
jti gives the token a unique id. It lets a server detect a token being replayed, or put a single token on a deny list without blocking all of a user's tokens.
3Is the Payload Secret?
No. A signed JWT, formally a JWS, is only encoded. Anyone who holds the token, a browser extension, a proxy log, a support engineer reading a bug report, can decode the payload with one line of code and no key.
So everything in the payload should be treated as public to anyone who can see the token. If we truly need to hide its contents, there is JWE, JSON Web Encryption, which encrypts the payload for a recipient's key. But JWE adds key management and makes tokens harder to debug, so the usual answer is simpler: keep sensitive data such as email addresses, phone numbers or account details out of the token and let services look it up when they need it.
4What the Signature Protects
The signature covers both the header and the payload. If anyone changes a single character, for example sub from user-42 to user-43, or alg in the header, the signature no longer matches and verification fails. That is the guarantee a JWT gives: integrity and origin, meaning the contents are exactly what the issuer wrote. It does not give confidentiality, and it does not prove the token is still wanted, which is why expiry and, where needed, revocation checks matter as much as the signature.
Notice that the verifier must decide the algorithm from its own configuration, not blindly from the header. Otherwise an attacker could change alg to none, or to HS256 using the public key as a secret, attacks that well-configured libraries such as Spring's NimbusJwtDecoder reject.
5Follow-up questions
What is the difference between an ID token and an access token if both are JWTs?
An ID token, from OpenID Connect, tells the client who logged in and has the client as its audience. An access token is meant for an API, carries scopes, and has the API as its audience. A client should not send ID tokens to APIs, and APIs should not accept them.
Why can aud be a string or an array?
RFC 7519 allows both, because a token may be meant for one or several recipients. Spring Security normalises it to a list, so a validator can always check whether the list contains its own name.
Should I put the user's roles in the token?
Coarse roles or scopes that the API needs for authorization are fine. Long, frequently changing permission lists or personal data are not, because the token is readable, grows every request, and becomes stale until it expires.
6Conclusion
In this answer, we took a JWT apart. It has a header with alg, typ and kid, a payload of claims and a signature, all base64url encoded and joined by dots. The registered claims are iss for the issuer, sub for the subject, aud for the audience, exp for expiry, nbf for not before, iat for issued at and jti for a unique id. The payload of a signed JWT is readable by anyone holding it, so secrets need JWE or, better, stay out of the token, while the signature over header and payload makes any change detectable.
Open with
A JWT has three parts, each base64url encoded and separated by dots. The header says how it is protected: alg is the signing algorithm such as RS256, typ the token type, and kid the id of the signing key, which the verifier uses to pick the right public key.
Then, if they want more
The payload holds the claims, and the third part is the signature over the encoded header and payload.
The registered claims are iss, the issuer that created the token; sub, the subject it is about, unique within that issuer; aud, the audience that should accept it, so one API does not accept another API's tokens; exp, the expiry time; nbf, the time before which it is not valid; iat, when it was issued; and jti, a unique id that helps with replay detection or revoking a single token.
The time claims are seconds since the epoch, and verifiers allow a little clock skew, sixty seconds by default in Spring Security. The payload is not secret. A signed JWT is only encoded, so anyone with the token can decode it without a key.
If contents must be hidden, JWE can encrypt them, but usually we just keep personal or sensitive data out of the token. The signature gives integrity: changing any character of header or payload makes verification fail.
About this answer
- Last updated
- 12 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- RFC 7519, JSON Web Token
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "Describe the structure of a JWT and the meaning of the registered claims iss, sub, aud...": https://scrivio-interview-library.netlify.app/spring-boot/jwt/0720f02040/