A signed container of claims
The issuer places claims in the payload and signs the encoded header and payload. The receiver verifies the signature with a trusted key.
A visual, practical guide to JWT structure, claims, signatures, expiry, access tokens, refresh tokens, validation, logout, and secure API authentication.
A JWT is a compact string that can carry claims and be cryptographically signed. Authentication protocols decide how it is issued, transported, refreshed, and revoked.
The issuer places claims in the payload and signs the encoded header and payload. The receiver verifies the signature with a trusted key.
The header and payload are normally Base64URL encoded, not encrypted. Anyone holding the token can often read them.
A valid signature does not automatically grant access. The API still checks audience, scopes, roles, tenant, resource ownership, and policy.
A signed JWT, also called a JWS compact serialization, has three dot-separated Base64URL segments.
{ "alg": "RS256", "typ": "JWT" }Names the token type and signing algorithm. The API must restrict algorithms to a trusted allowlist.
{ "sub": "user-1042", "aud": "orders-api", "exp": 1783000000 }Contains registered and application claims. It is readable and should not contain passwords or private secrets.
Sign(base64Url(header) + "." + base64Url(payload), key)Protects integrity and authenticity. It does not encrypt the payload or hide its values.
Registered claims provide common meanings. Private claims add application data, but both require server-side validation and authorization rules.
issWho created the token. Accept only trusted issuers.
subThe user, service, or entity represented by the token.
audThe intended receiver, commonly a particular API.
expThe time after which the token must be rejected.
nbfThe token must not be accepted before this time.
iatWhen the issuer created the token.
jtiA unique identifier useful for tracing or revocation strategies.
scopeDelegated capabilities such as orders.read.
The JWT is only one part of a larger authorization and session lifecycle.
The user signs in or the application completes an authorization flow.
A trusted authorization server creates a short-lived access token.
The client sends Authorization: Bearer ACCESS_TOKEN to the intended API.
The API verifies signature, algorithm, issuer, audience, time claims, and permissions.
After expiry, the client may use a protected refresh token with the authorization server.
Sent to the resource API. Keep it short lived. It may be a JWT or an opaque value.
Sent only to the authorization server. Protect it strongly, rotate it, and support revocation.
Tells the client about an authenticated user. Do not use it as a general API access token.
A decoded token can be fake, expired, intended for another API, or signed by an untrusted key.
Short-lived access tokens authorize calls to backend resources.
OpenID Connect may deliver an ID token containing identity claims for the client.
Workload identities obtain scoped tokens without representing a human user.
Short-lived signed tokens can carry bounded claims, but replay and audience controls still matter.
Answers for developers learning token structure, authentication, validation, and session security.
JWT stands for JSON Web Token. It is a compact format for carrying signed claims between systems. A JWT can identify a subject and carry authorization-related data, but the receiving system must validate it before trusting it.
Usually no. Standard signed JWT header and payload segments are Base64URL encoded and readable. Encryption requires a different form called JWE. Never place passwords or secrets in a normal JWT payload.
A signed JWT normally contains a header, payload, and signature separated by dots. The header describes the algorithm, the payload contains claims, and the signature protects the token from undetected modification.
Yes, the header and payload can usually be decoded without a key. Decoding does not prove that the token is authentic. Verification requires the trusted secret or public key and validation rules.
Decoding reads the header and payload. Verification checks the cryptographic signature and validates issuer, audience, expiry, not-before time, algorithm, and application authorization rules.
No. Access tokens may be JWTs or opaque random strings. Clients should treat an access token as an opaque credential unless the authorization server explicitly documents its format.
It can be, but many systems use opaque refresh tokens. A refresh token is a high-value secret sent only to the authorization server to obtain a new access token.
The exp claim is the expiration time expressed as a NumericDate, normally seconds since the Unix epoch. A token should be rejected after this time, with only a small configured clock-skew allowance.
iss identifies the trusted token issuer. aud identifies the intended audience, such as a specific API. APIs should validate both to prevent accepting a token created for another system.
There is no universal choice. Secure, HttpOnly, SameSite cookies or a backend-for-frontend are common. JavaScript-readable storage increases exposure during XSS, while cookie-based sessions require appropriate CSRF controls.
The app clears its local session and normally revokes the refresh token. Short-lived JWT access tokens may remain usable until expiry unless the API performs additional server-side revocation or session checks.
No. JWT is a token format. OAuth 2.0 is an authorization framework, and OpenID Connect adds identity. An OAuth system can issue JWT or opaque access tokens.
Suggested tools