top of page

What is JWT (JSON Web Token)?

Oct 27
8 min read

Updated: Oct 28

What is JWT (JSON Web Token)?

 

A JSON Web Token, usually shortened to JWT and often pronounced “jot”, is a compact format for carrying claims between parties. Claims are statements represented as JSON, such as the issuer, intended recipient or expiry time. A JWT can be signed or protected with a message authentication code, encrypted, or used in a nested combination, depending on the application.

 

A JWT is a format, not a complete authentication or authorisation system. The receiving application must establish whether the token came from a trusted source, is intended for that recipient, is valid for the current time and purpose, and permits the requested action. Simply decoding a JWT does not prove that it is trustworthy.

 

The JSON Web Token specification, RFC 7519, defines the format and registered claims. The rules for a particular application or protocol determine which claims and validation steps are required.

 

How a JWT works

 

An issuing system creates a set of claims for a particular use. It packages the claims using an appropriate JSON Web Signature (JWS) or JSON Web Encryption (JWE) structure. A client may carry the resulting token to an intended recipient, which applies the checks required by the relevant protocol before relying on the claims.

 

The illustration shows the parts and checks associated with a typical signed JWT: a header, claims, a signature and validation by the receiving service. Encrypted and nested JWTs use different structures and require their own checks.

 

JWT infographic showing a signed token header, claims, signature and validation

 

  1. The issuer prepares claims for a specific token type and intended recipient.

  2. The issuer creates a signed or otherwise protected token using the chosen format and keys.

  3. The client sends the token securely to the intended service.

  4. The service applies the relevant cryptographic and claim checks.

  5. The service enforces its own permissions before returning protected data.

 

A real sign-in or API flow may involve additional steps such as redirect validation, client authentication, proof of possession or token exchange. The correct checks come from the protocol and application profile, not from the JWT format alone.

 

The three parts of a signed JWT

 

A common signed JWT uses compact JWS serialization and has three sections separated by full stops: an encoded header, an encoded payload containing claims, and a signature or message authentication code. The first two sections are encoded using Base64url. Encoding is not encryption, so a recipient who obtains a typical signed token can read its header and claims.

 

Part

Purpose

What to remember

Header

Describes information about the token and cryptographic operation

Treat header values as untrusted until validated

Payload

Contains a JSON claims set

Claims are not necessarily confidential

Signature or MAC

Provides integrity protection when correctly checked

It does not by itself grant every permission

 

This three-part explanation applies to a compact signed JWT. A compact JWE has five sections and encrypts its content. Nested JWTs can combine signing and encryption. The JWT specification also describes unsecured JWTs for specific contexts; a secure application must not accept them unless its own explicitly configured protocol requires that behaviour.

 

Common JWT claims

 

Claim

Common meaning

Important point

iss

Issuer

Check against the expected trusted issuer where required

sub

Subject

Its meaning depends on the issuer and token profile

aud

Audience

Check that the token is intended for the receiving service

exp

Expiration time

Reject after expiry, subject to the profile's allowed clock tolerance

nbf

Not before

A token is not valid before this time when the claim applies

iat

Issued at

Indicates when the token was issued; it is not itself an expiry time

jti

JWT identifier

Can support identification or replay controls when the system uses it

 

These registered claims are optional in the base JWT specification. A particular token profile can require some of them and define how they must be interpreted. A subject may represent a user, application or another principal. A claim only has the meaning and trust established by the relevant issuer, protocol and validation rules.

 

Is a JWT encrypted?

 

Not necessarily. A typical signed JWT protects its integrity, but its header and payload can still be decoded and read. Do not put passwords, secrets or unnecessary personal information into a token merely because the contents look encoded.

 

An encrypted JWT uses JWE to protect confidentiality for the intended recipient. Encryption and signing address different properties, and a design may use both. HTTPS remains important for protecting tokens and requests in transit even when a token itself is encrypted.

 

Treat any usable bearer token as sensitive. Someone who obtains it may be able to replay it until it expires or another effective control prevents use. Do not paste live tokens into public decoder websites, screenshots, support tickets or logs.

 

How should a JWT be validated?

 

The recipient needs a trusted configuration established independently of the incoming token. A maintained library can perform cryptographic checks, but the application still has to configure the correct keys, permitted algorithms, issuer, audience and rules for the token's intended use.

 

  1. Identify the expected token type, issuer and intended recipient before processing the token.

  2. Use only appropriate, explicitly permitted algorithms and trusted keys for that issuer and profile.

  3. Verify every required signature, MAC or encryption operation and reject failures.

  4. Validate issuer, audience, expiry and other required claims under the applicable profile.

  5. Apply any protocol-specific checks, including transaction binding where relevant.

  6. Enforce permissions for the requested operation and resource.

 

The JWT Best Current Practices, RFC 8725, explains risks such as algorithm confusion, weak keys and accepting one kind of JWT in a context intended for another. Do not let an untrusted token select an arbitrary verification algorithm or remote key location. Token type and validation rules should prevent an ID token intended for a client being accepted as an access token for an API.

 

Key rotation also needs a trusted process. An issuer may publish a changing set of verification keys, but the application must obtain them from a configured, trusted location and handle rollover safely. A key identifier in a token is a hint for selecting an appropriate trusted key, not an instruction to trust any key supplied by the token.

 

JWTs, access tokens and ID tokens

 

Token based authentication describes a broader pattern for using tokens in a trusted relationship. JWT describes a token format. An access token can be a JWT or an opaque value, depending on the provider and profile.

 

OAuth access tokens are intended for protected resources. Their contents and validation depend on the authorisation server and API. The JWT access token profile, RFC 9068, sets specific requirements for deployments that choose that profile; it does not mean every OAuth access token must be a JWT.

 

OpenID Connect defines an ID token that communicates authentication claims to a relying application. An ID token is intended for that application and is not a general-purpose API access token. An API needs an appropriate access token and its own authorisation checks.

 

Item

Purpose

Is it always a JWT?

JWT

Format for representing claims in a protected or, in special contexts, unsecured structure

It is the format itself

OAuth access token

Conveys access to a protected resource

No

OpenID Connect ID token

Communicates authentication claims to a relying client

Defined as a JWT

Session identifier

Connects a client to a session managed by an application

No

 

JWTs and server-side sessions

 

A JWT can carry claims that a recipient validates without looking up every request in a central session store, provided the design and token profile allow it. That can reduce some network lookups, but it does not remove all state. Keys, policies, account status, permissions, revocation and refresh mechanisms still need management.

 

A server-managed session can use a random identifier stored in a cookie, with session details kept on the server. A cookie is a transport and storage mechanism; it can carry different kinds of value. A JWT can also be stored in a cookie. Neither approach is automatically safer or more scalable in every situation.

 

The trade-off depends on the application. A locally validated token may remain acceptable until expiry unless the service checks revocation or account state. A centrally managed session can support immediate invalidation if all relevant components honour it, but the session store and its availability must be managed.

 

Expiry, refresh and revocation

 

An expiry limits the time during which a token is accepted when the recipient enforces it. A short lifetime can reduce the window for misuse but cannot prevent a token being stolen or replayed while valid. Clocks need appropriate synchronisation and a carefully bounded tolerance.

 

Refresh tokens, where issued, can allow a client to obtain replacement access tokens. They are separate credentials and require protection. Signing out of an application, revoking a refresh token, removing a grant and invalidating an existing access token can have different effects. Test the actual provider and API rather than assuming all tokens stop working immediately.

 

A compromised signing key can affect many tokens. Have a plan for key rollover, removing trust in compromised keys, investigating affected services and communicating with users where necessary. Retain old keys only for as long as needed under the intended validation and rotation policy.

 

A practical UK example

 

Imagine a UK support business operating a case portal and a separate monitoring API. This is an illustrative design, not a tested deployment or a claim about a particular provider.

 

The portal receives a token intended for the monitoring API. The API verifies it against a trusted issuer, checks its intended audience and expiry, and then decides whether the engineer may view the requested customer's data. A valid signature does not itself settle that customer-specific decision.

 

Request

Intended result

Check

Engineer requests an assigned customer's report

Allow when all checks pass

Token validation and customer-level permissions

Token is intended for a different API

Reject

Audience and token type

Token has expired

Reject or follow the supported renewal process

Expiry and clock policy

Engineer has left the business

Remove access under policy

Account state, session, grants, tokens and caches

 

A claim can become stale when a person's role changes. The design must account for the time between a change and its effect on each API, including token lifetime and any policy or revocation checks.

 

Common JWT problems

 

  • Wrong issuer or audience: the token is not intended for the configured trust relationship.

  • Expired or not-yet-valid token: check the time claims and clock synchronisation.

  • Signature failure: the token, algorithm or trusted key does not match expectations.

  • Key rollover failure: the service has not obtained the current trusted verification key.

  • Valid token but denied request: the caller lacks the required permission or resource access.

  • Different token type accepted incorrectly: validation rules do not distinguish tokens issued for separate purposes.

 

Use safe request identifiers and timestamps to trace the problem across the issuer, client and API. Do not log complete tokens. Test failure cases with authorised test accounts and non-sensitive data, including revoked access, wrong audiences, invalid signatures and key rollover.

 

Key takeaway

 

A JWT is a compact way to represent claims, not proof that those claims are true or confidential. Correct security depends on the token profile, trusted keys, cryptographic and claim validation, secure handling and the receiving service's permission checks.

 

Frequently asked questions

 

What does JWT stand for?

 

JWT stands for JSON Web Token, a compact format for representing claims between parties.

 

Is every JWT encrypted?

 

No. A signed JWT is not necessarily encrypted, and its encoded claims can often be read. An encrypted JWT uses a JWE structure.

 

Does decoding a JWT verify it?

 

No. Decoding reveals its contents. The recipient must perform the cryptographic and claim checks required for the token's intended use. Use a maintained library and the intended token profile to check the permitted algorithm, trusted key, issuer, audience and applicable time claims. Reject tokens meant for another purpose. Never treat a readable subject or role claim as authoritative before those checks succeed.

 

Are all OAuth access tokens JWTs?

 

No. An access token can be opaque or use a JWT profile, depending on the authorisation server and resource server.

 

Can I use an ID token to call an API?

 

An OpenID Connect ID token is intended for the relying client. An API should receive an appropriate access token intended for that API.

 

Can a JWT be revoked immediately?

 

Not automatically in every design. The effect depends on expiry, revocation checks, key trust, caches and the receiving service's implementation. For a self-contained token, deleting the issuer's record may not change what an API accepts locally. Check for supported introspection, denylisting or other revocation enforcement, and test an existing token after revocation. Short expiry limits exposure time but is not immediate revocation.

 

Should I put passwords in a JWT?

 

No. Avoid placing passwords, secrets or unnecessary personal information in token claims. A signed token's payload is not necessarily confidential.

 
 
UK Techie Broadband Providers
bottom of page