JWT Explained: How Tokens Prove Who You Are Online

JWT explained in plain terms means a small, signed token that carries proof of who you are, so that services can trust you without asking a central authority every time. The central question is how a website knows you are signed in when you move from page to page, and the short answer is that it gives you a token, a sealed envelope containing your identity, which you show at every door instead of typing your password again.

Think of a wristband at a festival. You show your ticket once at the entrance, and you receive a wristband that every gate inside accepts without question. The wristband is hard to forge, it says who you are and what you can access, and it expires when the festival ends. A JWT is the wristband of the web.

JWT stands for JSON Web Token, and it is one of the most common ways modern applications handle sign-in. It appears in single-page apps, mobile apps, and the connections between services, wherever a system needs to prove identity quickly and without a shared session.

Key takeaways

  • A JWT is a signed token carrying claims about who you are and what you may do.
  • It has three parts: a header, a payload, and a signature that proves it is genuine.
  • Any service with the right key can verify a token without contacting the issuer.
  • Tokens expire, which limits the damage if one is stolen.
  • JWTs prove identity; they do not encrypt the data inside, which anyone can read.

What a JWT is

A JSON Web Token is a compact, self-contained way of carrying information between two parties, defined by an open standard. It is a string of three sections, separated by dots, each encoded in a web-safe form. The first section, the header, says what kind of token it is and which signing method was used. The second, the payload, holds claims, statements such as who the user is, when the token was issued, and when it expires. The third, the signature, is produced by signing the first two sections with a secret key, and it is what makes the token trustworthy.

The signature is the crucial part. Anyone can read a token’s payload, because it is only encoded, not encrypted, but nobody can change it without breaking the signature. A service that receives a token recomputes the signature with its key, and if the result matches, it knows the token was issued by someone it trusts and has not been altered since. That check takes milliseconds and needs no database lookup.

Tokens are usually issued after a successful sign-in. The user proves who they are once, with a password or another check, and the authentication service hands back a token. The user, or rather their browser or app, includes that token in every later request, usually in a header, and each service verifies it independently before answering.

JWTs are a standard, not a product, and they are used by countless systems. Our guide to OAuth explains the wider system in which JWTs often appear, where one service grants another permission to act on a user’s behalf.

How a JWT works

It begins with sign-in. The user sends their credentials to an authentication service, which checks them and builds a token: a header naming the signing method, a payload with claims such as the user’s identifier and an expiry time, and a signature created with the service’s secret key. The token is returned to the user, and the sign-in is complete.

On every later request, the client sends the token along, typically in an authorisation header. The receiving service splits the token into its three parts, recomputes the signature over the header and payload using the key it trusts, and compares the result with the signature the token carries. If they match, the token is genuine. If they do not, the token has been tampered with, and the request is refused.

The service also checks the claims. It confirms the token has not expired, that it was issued by the expected authority, and that it is intended for this service. Only then does it trust the identity inside and decide what the user is allowed to do, using the roles or permissions the payload may carry.

Because verification needs only the key, not a call to the issuer, JWTs scale well. A dozen services can each verify the same token independently, which is why they are popular in systems built from many small services. The trade-off is that a token, once issued, cannot easily be taken back: it remains valid until it expires, which is why expiry times are kept short.

A photograph of a hand holding a smartphone glowing green with a padlock symbol in a dark room at night
A JWT is a sealed envelope: anyone can read the claims inside, but only the issuer’s signature proves they have not been changed.

Comparing JWTs with server sessions

Aspect Server session JWT
Where state lives On the server, in memory or a store In the token, carried by the client
Verifying a request Look up the session Check the signature locally
Scaling across servers Needs shared session storage Any server with the key can verify
Revoking access Delete the session at once Hard: must wait for expiry or keep a list
Best for Traditional websites APIs and distributed services

Where JWTs are used

Single-page web applications are the classic case. The browser holds the token after sign-in and sends it with every request to the API, which verifies it without keeping any session of its own. This keeps the API stateless, which makes it easy to scale across many servers, since no server needs to remember who is signed in.

Mobile apps use JWTs the same way. The app stores the token securely on the device and includes it in requests, refreshing it when it expires. Because the token is self-contained, the app can talk to many different services with the same proof of identity, without each one needing to know about the others.

Service-to-service communication is another major use. When one service calls another on a user’s behalf, it passes the user’s token along, so the receiving service knows who the request is for and can enforce the same permissions. Our guide to API security explains the wider protections around these calls, of which tokens are only one part.

JWTs also appear in single sign-on systems, where one login produces a token that many applications accept. The user signs in once, receives a token, and each application verifies it independently, which is simpler than every application running its own sign-in.

Strengths and limits

The greatest strength of a JWT is that it is self-contained and stateless. A service can verify a token with only a key, no database, no shared session store, and no call to the issuer. That makes systems simpler to scale and easier to spread across servers and regions.

It is also a standard, which means libraries exist in every language, and tokens issued by one system can be verified by another. That interoperability is why JWTs appear in so many products and platforms, from small apps to enterprise identity systems.

Its limits are real and often misunderstood. A JWT is not encrypted by default: anyone who holds one can read its payload, so sensitive information must never be put inside. The signature proves the token is genuine, but it does not hide its contents, and developers who treat tokens as secret have leaked user data.

Revocation is the other hard problem. A stolen token remains usable until it expires, and there is no built-in way to cancel it. Short expiry times and refresh tokens limit the risk, but they do not remove it, and systems that need instant revocation must keep a list of cancelled tokens, which reintroduces the state that JWTs were meant to avoid.

JWT checklist

  • Keep tokens short-lived and refresh them with a separate refresh token.
  • Never put sensitive data in the payload: it is readable by anyone.
  • Always verify the signature and the expiry time on every request.
  • Use strong signing keys and keep them secret.
  • Check the issuer and audience claims match what you expect.
  • Store tokens securely on the client, never in plain text or URLs.
  • Plan for revocation: know what happens when a token is stolen.
  • Use a trusted library rather than writing token handling by hand.
  • Send tokens only over encrypted connections.

Frequently asked questions

What is a JWT?

A JWT, or JSON Web Token, is a compact, signed token that carries claims about a user, such as their identity and an expiry time. It has a header, a payload, and a signature, and any service with the right key can verify it without contacting the issuer.

Is a JWT encrypted?

Not by default. A JWT is encoded, not encrypted, so anyone who holds it can read the payload. The signature proves the token is genuine and unaltered, but it does not hide the contents, so sensitive data must never be placed inside.

How does a server verify a JWT?

It splits the token into its three parts, recomputes the signature over the header and payload using the key it trusts, and compares the result with the signature the token carries. It also checks the expiry time and the issuer before trusting the claims inside.

What happens if a JWT is stolen?

The thief can use it until it expires, which is why tokens are kept short-lived. There is no built-in way to cancel a JWT, so systems use short expiry times, refresh tokens, and sometimes a list of revoked tokens to limit the damage.

What is a refresh token?

A refresh token is a longer-lived credential used to obtain new short-lived access tokens without asking the user to sign in again. It is stored more carefully than the access token, and it can be revoked by the server when needed.

When should I use JWTs instead of sessions?

For APIs and distributed systems, where many services must verify identity without shared state. For a traditional website with a single server, a server-side session is often simpler and easier to revoke.

The bottom line

JWT explained in one line is this: a signed, self-contained token that proves who you are, verifiable by any service that holds the key, without asking anyone else.

Keep tokens short-lived, never put secrets in the payload, and remember that a signature proves a token is genuine, not that its contents are private. Used with those rules, JWTs are a clean and scalable way to carry identity.

This article is general information about how JWTs work, not advice about how to design authentication for a particular system.

Latest articles

Scroll to Top