Short answer
A JWT is a compact way to send JSON claims, usually signed so the receiver can check they were not changed. RFC 7519 defines it for small places such as an HTTP Authorization header. In the common signed form, the token is three Base64url parts separated by dots: header, payload, and signature. The signature is what makes the claims trustworthy.
Last verified against the sources listed below.
Key takeaways
- RFC 7519 says a JWT is always the JWS or JWE compact serialization.
- Registered claims iss, sub, aud, exp, nbf, iat, and jti are all optional.
- exp is the time on or after which the token must not be processed.
- If aud is present and the receiver is not in it, the token must be rejected.
- An alg value of none produces an unsecured JWT with an empty signature.
- Claims the application does not understand must be ignored, not rejected for that reason alone.
what is jwt is a format question. RFC 7519 defines a JSON Web Token as a compact claims representation for tight spaces such as an HTTP Authorization header or a URI query parameter. The suggested pronunciation is the same as the English word “jot.”
The claims are a JSON object. That object is the payload of a JSON Web Signature, or the plaintext of a JSON Web Encryption, so the claims can be signed, integrity-protected with a MAC, encrypted, or both. A JWT is always represented with the JWS compact serialization or the JWE compact serialization.
This article stays with the signed form, because that is the token most APIs pass around. How the internet works explains the HTTP request that carries it. The token does not replace TLS.
What are the three parts?
A signed JWT in compact form is three Base64url segments separated by dots.
RFC 7515 writes the JWS compact serialization as BASE64URL of the UTF-8 protected header, a period, BASE64URL of the payload, a period, and BASE64URL of the signature. RFC 7519 uses that same shape. The header describes the cryptographic operation.
The payload is the claims set. The third part is the signature or MAC over the first two parts.
RFC 7519’s own example uses the header {"typ":"JWT","alg":"HS256"}. After Base64url encoding, that header begins eyJ0eXAiOiJKV1Qi. The example payload contains an issuer, an expiration, and one extra claim.
The signature in the RFC is dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk. The hyphen and underscore are Base64url characters. They are not line breaks.
The RFC shows line breaks only so the sample fits on a page.
The header’s alg names the algorithm. HS256 in the example means HMAC using SHA-256.
MDN’s Base64 glossary says the URL-safe variant replaces plus and slash with minus and underscore. Those are the characters you see in a JWT segment. RFC 4648 is the specification MDN names for that alphabet.
The signature is not proof by itself if the receiver does not know which key belongs with that algorithm. RFC 7515 says the signature is not valid when alg is unsupported or when no key is associated with it.
Which claims are registered?
Seven registered claim names are defined. None of them is mandatory.
RFC 7519 section 4.1 says the names are short because the token should stay compact. Applications decide which claims they require. Any claim an implementation does not understand must be ignored.
Duplicate claim names are not allowed. A parser must reject the token or keep only the lexically last duplicate.
| Claim | Meaning in RFC 7519 |
|---|---|
| iss | Principal that issued the JWT. A case-sensitive string |
| sub | Principal the JWT is about. Locally unique for that issuer, or globally unique |
| aud | Recipients the JWT is for. A string, or an array of strings |
| exp | Expiration time. On or after this time the JWT must not be processed |
| nbf | Not-before time. The token must not be processed earlier |
| iat | Issued-at time. Can be used to judge the token’s age |
| jti | Unique ID for this JWT. Can be used to stop replay |
iss, sub, and aud are StringOrURI values. If the string contains a colon, it must be a URI, and they are compared as case-sensitive strings with no rewriting.
exp, nbf, and iat are NumericDate values: a JSON number of seconds from 1970-01-01T00:00:00Z UTC, ignoring leap seconds. The RFC allows a small leeway for clock skew on exp and nbf, usually no more than a few minutes.
If aud is present, every principal that processes the token must find itself in that claim, or the JWT must be rejected. A single audience may be a string instead of a one-element array.
iss does not get that automatic rejection rule. The RFC says processing of iss is generally application specific.
The IANA JWT claims registry lists iss, sub, aud, exp, nbf, iat, and jti, each pointing back to RFC 7519. Later rows, such as name for a full name, cite OpenID Connect instead.
Public claim names are names you register or names built to avoid collisions. Private claim names are a private agreement between producer and consumer. The RFC says private names can collide and should be used with caution.
The example token includes a private claim, http://example.com/is_root, next to iss and exp. For duplicate names, RFC 7519 cites the JSON object rule in ECMAScript 5.1.
What must validation check?
Reject the token if the structure fails, if the signature fails, or if an included time or audience claim fails.
Section 7.2 lists the steps. The order can change when a later step does not depend on an earlier one. Any failed step rejects the token.
The checker confirms at least one period, decodes the header as JSON, and keeps only header parameters it understands. It then validates the JWS or the JWE using that specification. For a JWS, that is the signature check in RFC 7515.
After the payload is decoded, it must be a JSON object. That object is the claims set.
Time and audience checks come from the claim definitions, not from a separate slogan. If exp is present, the current time must be before that expiration. If nbf is present, the current time must be after or equal to that instant.
If aud is present, the receiver must be listed. The RFC also says that a token can verify and still be unacceptable. Unless the algorithms are acceptable to the application, the application should reject the token.
That sentence is how you refuse alg of none when you required a signature.
An unsecured JWT is allowed by section 6. It is a JWS with alg set to none and an empty signature string. The example header is {"alg":"none"}, which encodes to eyJhbGciOiJub25lIn0.
Website security covers why an empty signature is not authentication. RFC 7519 section 11.1 says the contents cannot be relied on for a trust decision unless they have been cryptographically secured, and the key is typically under the control of the issuer.
How does a signature relate to encryption?
Signing and encryption are different layers. When you need both, sign first and then encrypt.
A signed JWT shows its claims to anyone who can Base64url-decode the payload. The signature detects changes. It does not hide the JSON.
An encrypted JWT is a JWE. The claims are plaintext inside the encryption, so a reader without the key does not get the JSON. Nested tokens can wrap one JWT in another.
When nesting is used, the outer header’s cty value must be JWT.
Section 11.2 says producers who both sign and encrypt should sign the message and then encrypt the result, which encrypts the signature too. That order stops a class of attack that strips the signature and leaves only ciphertext, and it keeps the signer private. JWE already requires authenticated encryption, so the RFC says the old worry about signing after encryption does not apply here in the same way.
Privacy has its own section. If the token holds private information, you either encrypt it and authenticate the recipient, or you send an unencrypted token only over a protocol such as TLS that encrypts the connection and authenticates the endpoint. Omitting the private claim is the simplest option. Copying iss, sub, or aud into the header of an encrypted token is only for values that are safe to expose before decryption.
What do people get wrong?
They trust the payload without checking the signature, or they treat every registered claim as required.
The middle segment is ordinary JSON once you decode it. Anyone can edit the bytes and re-encode them. The third segment is what binds those bytes to a key.
Skipping that check, or accepting alg none, makes the issuer and the subject whatever the sender typed. The case converter only changes the letters of a label while you read a header. It does not validate a token, and claim names such as iss are lowercase on purpose.
Another miss is rejecting a token because an unknown claim appeared. The RFC says the opposite. Unknown claims must be ignored unless the application has its own rule.
The matching miss is accepting a token after exp. The expiration is the time on or after which processing must stop, aside from the small clock skew the implementer chose. aud is the same kind of hard stop when the claim is present and the receiver is not listed.
Frequently asked questions
How does JWT authentication work?
RFC 7519 does not define a login flow. It defines a token. In practice an API treats a signed JWT as a set of claims about a subject, then validates it with the steps in section 7.2. The application decides which algorithms it accepts, and it should reject a token whose algorithm is not on that list even if the bytes verify. The issuer claim is optional.
What is a JWT token's typ header?
typ is an optional header parameter. RFC 7519 says it declares the media type of the complete JWT, and it recommends the value JWT, spelled in uppercase, when the surrounding format might also hold other objects. Implementations of JWT ignore typ. The application may read it to tell a JWT apart from something else. When the object is already known to be a JWT, the RFC says typ will typically not be used. cty is a different header.
What is JWT validation required to do first?
Section 7.2 starts by checking that the token contains at least one period. The encoded JOSE header is the portion before the first period. The next steps Base64url-decode that portion, with no added whitespace or line breaks, and require the result to be UTF-8 JSON. The header may contain only parameters the implementation understands or parameters the spec says to ignore. Only then does the verifier decide whether the token is a JWS or a JWE and follow that specification.
How does JWT work in an API header?
The introduction says the format is meant for space-constrained environments such as Authorization headers and URI query parameters. The compact form is URL-safe because each part is Base64url, not ordinary Base64 with plus and slash. The claims are a JSON object, so names and values travel in the payload, not as separate headers, unless an encrypted token copies iss, sub, or aud into the header on purpose. Those copies are for encrypted tokens that need a routing hint before decryption.
What does the jti claim add?
jti is the JWT ID. RFC 7519 says the value must be assigned so the chance of an accidental repeat is negligible. If more than one issuer exists, values must not collide across issuers either. The claim can be used to prevent the token from being replayed. It is a case-sensitive string, and it is optional. It does not replace exp. A unique ID with no expiration still needs the application to remember IDs it has already seen. The RFC does not require a store or a cache.
Sources
- RFC 7519: JSON Web Token (JWT) · IETF, 2015
- RFC 7515: JSON Web Signature (JWS) · IETF, 2015
- JSON Web Token (JWT) claims registry · IANA, 2026
- Base64 · MDN, 2026
- RFC 4648: The Base16, Base32, and Base64 Data Encodings · IETF, 2006
- ECMAScript Language Specification, 5.1 Edition · Ecma International, 2011