typ (Type) Header Parameter in a JWT
typ declares what kind of token this is, using a media type. It is optional in RFC 7515 but is the mechanism that stops one kind of signed token being accepted where a different kind was expected.
At a glance
- Parameter
- typ (Type)
- Defined in
- RFC 7515 section 4.1.9
- Value type
- String, a media type with the application/ prefix conventionally omitted
- Required
- Optional in RFC 7515. Required as at+jwt in an RFC 9068 access token.
- Common values
- JWT, at+jwt for access tokens, dpop+jwt for DPoP proofs, logout+jwt
- In the decoder
- Shown in the header JSON. A missing typ produces an informational note in the validation list.
In detail
The value is a media type with the application/ prefix left off by convention, so JWT rather than application/JWT. RFC 7515 makes it optional and says it is intended for use by the application rather than by the JOSE layer, which is why so many tokens carry the uninformative value JWT and nothing more specific.
Cross token confusion is what a specific value prevents. An authorization server signs several different documents with the same key: ID tokens, access tokens, logout tokens, and possibly software statements. If none of them say what they are, a resource server that only checks the signature and the claims can be handed a logout token and find enough familiar claims in it to proceed.
RFC 9068 fixes that for access tokens by requiring the value at+jwt, and instructing resource servers to reject anything else. DPoP proofs use dpop+jwt for the same reason. The pattern generalizes: give each kind of token its own type, check it explicitly, and one signing key stops being a way to substitute one document for another.
The decoder shows typ in the header JSON exactly as it was encoded and adds an informational line to its validation list when the parameter is missing, since its absence is worth noticing rather than an error in itself. It does not know which type your application expects, so the comparison against at+jwt or anything else stays in your own verification code.
Examples
// OpenID Connect ID token
{ "alg": "RS256", "typ": "JWT", "kid": "2024-06-key" }
// RFC 9068 access token
{ "alg": "RS256", "typ": "at+jwt", "kid": "2024-06-key" }
// DPoP proof, made by the client
{ "alg": "ES256", "typ": "dpop+jwt" }Same signing key for the first two. Only typ tells a resource server which document it is holding.
Things that catch people out
- Comparing typ case sensitively against JWT. RFC 7515 notes the value is case insensitive in practice, and issuers emit both cases.
- Accepting an access token with typ set to JWT when your profile requires at+jwt. The requirement exists to stop another token type being substituted.
- Assuming typ describes the payload. That is what cty does; typ describes the complete token.
Try it: JWT Decoder
Paste a token to decode the header and payload, read the claims and expiry, and verify the signature in your browser. Nothing is uploaded.
JWT Decoder
LOCAL · Browser-OnlyDecode and inspect JSON Web Tokens without sending them to a server
Related JWT claims and algorithms
All jwt claims and algorithms →cty (Content Type) Header Parameter in a JWT
The cty header describes the payload rather than the token. How the value JWT signals a nested token, and when nesting is actually worth it.
alg (Algorithm) Header Parameter in a JWT
The alg header names the algorithm used to sign a JWT. Why the accepted algorithms belong in configuration, and what the decoder does with the value.
sid (Session ID) Claim in a JWT
The sid claim identifies the authentication session at the provider. How single logout uses it, why it is not the user identifier, and decoder behaviour.
kid (Key ID) Header Parameter in a JWT
The kid header says which key signed a token. How rotation depends on it, why the value must be a lookup and never a path, and decoder behaviour.
jku (JWK Set URL) Header Parameter in a JWT
The jku header points at a JWK Set URL for the signing key. Why following it blindly gives an attacker both forgery and SSRF, and safe handling.
jwk (JSON Web Key) Header Parameter in a JWT
The jwk header embeds the public key in the token itself. Why trusting it verifies nothing, where it is legitimate, and how the decoder treats it.
Tools for this
- JWT Decoder Free online JWT decoder - decode and inspect JSON Web Tokens without sending them to a server