The three parts of a JWT are the header, the payload and the signature. Each part is Base64url-encoded and the three are joined with dots, as in header.payload.signature. The header says how the token is signed, the payload carries the claims, and the signature lets the receiver check that neither was changed.
How the three parts of a JWT fit together
A signed JWT is three Base64url strings separated by two dots: header, then payload, then signature. RFC 7515, section 3.1, defines this layout as the JWS Compact Serialization:
BASE64URL(header) . BASE64URL(payload) . BASE64URL(signature)
RFC 7519 calls a JWT "a compact, URL-safe means of representing claims", and section 3 says JWTs always use either this JWS form or the encrypted JWE form. Most tokens you see in an Authorization: Bearer header are the JWS kind.
Here is the example token from RFC 7519, section 3.1, split onto three lines for reading:
eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9
.
eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFtcGxlLmNvbS9pc19yb290Ijp0cnVlfQ
.
dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk
The encoding is the URL-safe Base64 alphabet from RFC 4648, section 5, with the trailing = padding removed. That's why JWTs contain - and _ but never +, / or =.
Part 1: the header
The header is a small JSON object that says what kind of token this is and which algorithm secured it. Decoding the first segment of the example gives:
{"typ":"JWT",
"alg":"HS256"}
algnames the algorithm. RFC 7515 says it "identifies the cryptographic algorithm used to secure the JWS" and that it must be present.HS256here means HMAC with SHA-256.typis optional. RFC 7519 recommends the value"JWT", and notes that JWT libraries themselves ignore it.
In the RFC example, the decoded header contains a CR LF line break after the comma. The encoded bytes are signed exactly as they are, so a JWT header doesn't have to be minified JSON. It just has to be byte-for-byte what was signed. Reformat it and re-encode it, and the signature no longer matches.
If you're choosing between algorithms for the alg field, see HS256 vs RS256.
Part 2: the payload (the claims)
The payload is a JSON object of claims: statements about the user or the token itself. The example decodes to:
{"iss":"joe",
"exp":1300819380,
"http://example.com/is_root":true}
RFC 7519, section 4.1, registers seven short claim names so different systems read them the same way:
| Claim | Meaning |
|---|---|
iss |
Who issued the token |
sub |
Who the token is about |
aud |
Who the token is meant for |
exp |
Time after which it must not be accepted |
nbf |
Time before which it must not be accepted |
iat |
When it was issued |
jti |
A unique ID for the token |
Times are seconds since the Unix epoch. The example's exp of 1300819380 is 2011-03-22T18:43:00Z, so that sample token expired long ago. The third claim, http://example.com/is_root, shows a custom claim; using a URL as the name avoids clashes with other issuers.
The payload is not encrypted. It's only encoded, so anyone holding the token can read it. Don't put passwords, card numbers or anything secret in a signed JWT's payload. The post on decoding a JWT without the secret shows how little it takes.
Part 3: the signature
The signature is what makes the first two parts trustworthy: it is computed over the encoded header, a dot and the encoded payload. RFC 7515, section 5.1, defines that signing input as:
ASCII(BASE64URL(header) . BASE64URL(payload))
For HS256, the issuer runs HMAC-SHA256 over that string with a shared secret, then Base64url-encodes the result. The example's third segment decodes to 32 raw bytes, the length of a SHA-256 output.
The receiver repeats the calculation with its key and compares. If one character of the header or payload changed, the result won't match and the token must be rejected. RFC 7515 describes this as integrity protection; for confidentiality it points to the separate JWE specification.
Reading a token and trusting it are two separate steps. Decode vs verify covers why the second step can't be skipped.
When a JWT doesn't have exactly three parts
Not every JWT has three filled parts: an unsecured JWT has an empty third part, and an encrypted JWT has five. Both are in the specs, and both trip up code that assumes token.split(".").length === 3.
Unsecured JWT (empty signature). RFC 7519, section 6.1, defines a token with the header {"alg":"none"}, which encodes to eyJhbGciOiJub25lIn0. Its signature is "the empty string", so the token ends with a trailing dot:
eyJhbGciOiJub25lIn0.eyJpc3MiOiJqb2Ui...fQ.
Never accept one of these where you expect a signed token. The alg none attack explains what goes wrong when a server does.
Encrypted JWT (JWE, five parts). RFC 7516, section 7.1, defines the JWE Compact Serialization with five dot-separated parts:
- Protected header
- Encrypted key
- Initialization vector
- Ciphertext
- Authentication tag
In a JWE, the claims sit inside the ciphertext and can't be read without the key. If you see four dots instead of two, you're looking at an encrypted token, and a plain decoder will show you only the header.
My take: when you parse tokens yourself, count the dots first. RFC 7519, section 7.2, starts validation with the same check, that the token "contains at least one period". Two dots means JWS, four means JWE, anything else gets rejected.
How to see the three parts of a real token
The quickest way to see the parts is to paste a token into a decoder that splits it at the dots and decodes the first two. The JWT decoder here shows the header, payload and signature, and turns iat and exp into readable times with an expired or valid flag.
The limitation: it only decodes. It does not verify the signature, so a token that looks fine in the decoder can still be forged or tampered with. Verification has to happen in your backend, with the key.
FAQ
What are the three parts of a JWT called?
The header, the payload (also called the claims set) and the signature. In the token they appear in that order, separated by two dots.
Is the JWT payload encrypted?
No. In a normal signed JWT the payload is only Base64url-encoded, so anyone holding the token can read it. Encryption needs a JWE, which is a different five-part format.
Can a JWT have more or fewer than three parts?
Yes. An unsecured JWT still has three parts but the last one is empty, so the token ends with a dot. An encrypted JWT (JWE) has five parts.
Which part of a JWT proves it wasn't changed?
The signature. It is computed over the encoded header, a dot and the encoded payload, so changing either one makes verification fail.
Can I decode a JWT without the secret key?
You can decode the header and payload without any key, because they are just Base64url. You need the key only to verify the signature.