What is a JWT?

In short
A JWT, or JSON Web Token, is a short, compact string that carries a set of claims, which are pieces of information about a user or system, from one party to another. Its contents can be signed so the receiver can check they were not changed, and optionally encrypted to hide them.
What a JWT looks like
A JWT is a text string. It has three parts separated by dots. The first part is a header that says how the token is protected. The second part is the payload, which holds the claims. The third part is a signature. Each part is encoded so it can be safely placed in a URL or an HTTP header.
A claim is a simple statement, written as a name and a value. For example, a claim might say who the user is or when the token expires. The claims are written as a JSON object, a common text format for structured data.
How it works
A server creates a JWT after it checks a user's login. It fills the payload with claims, adds a header, and signs the result with a secret key or a private key. The token is then sent back to the client.
Later, the client sends the token with each request. The server checks the signature before it trusts any claim. If the signature does not match, the token has been changed or was made by someone else, and the server should reject it.
The standard also defines a few registered claim names with fixed meanings. Examples include the issuer, which says who created the token, the subject, which says who the token is about, and the expiration time, which says when the token stops being valid. Using these names helps different systems understand each other.
When to use it
JWTs are often used for authentication and for passing permissions between services. Because the token carries its own information, the server does not always need to look up a session in a database. This can make systems simpler to scale.
JWTs are designed for small amounts of data. They fit well in HTTP Authorization headers and URL query parameters, where space is limited. For large or frequently changing data, another approach is usually better.
If you are new to web logins in general, you may want to read about HTTP cookies first, since they are a common alternative for keeping a user signed in.
A simple example
Here is what a decoded payload might look like. The claims are plain JSON:
{ "iss": "https://auth.example.com", "sub": "user-42", "exp": 1893456000 }
The iss claim names the issuer, sub names the subject, and exp gives the expiration time as a number of seconds since 1970-01-01 UTC. A receiver should check that the token is not expired before using it.
Note that a signed JWT is not hidden. Anyone who holds the token can read the payload, because it is only encoded, not encrypted. Do not put secrets like passwords inside it.
Common mistakes
The most common mistake is skipping validation. A server that reads the payload without checking the signature can be fooled by a forged token. Always verify the signature and the expiration time before trusting the claims.
Another mistake is storing sensitive data in the payload. Since the content is readable by anyone who has the token, keep private information out of it.
A third mistake is setting no expiration time. Tokens without an expiration can stay valid for a long time, even after a user should have lost access. Setting a clear expiry limits the damage if a token leaks.
Alternatives
Some systems use server-side sessions instead. The server keeps the session data and gives the client only an identifier. This makes it easier to revoke access right away, because the server controls the session. The trade-off is that the server must store and look up that data.
In the end, the choice depends on your needs. JWTs suit stateless checks across several services, while sessions suit cases where instant revocation matters most.
FAQ
Is a JWT encrypted?
Not by default. A standard signed JWT is encoded so it fits in a URL or header, but anyone holding it can read the payload. Encryption is a separate step that the standard also allows.
What does the signature in a JWT do?
The signature lets the receiver check that the token was not changed after it was issued. If the signature does not match, the server should reject the token.
How is a JWT pronounced?
The suggested pronunciation is the same as the English word jot. Many developers also say the letters one by one.
Should I store a JWT in local storage?
That depends on your threat model, and the choice has security trade-offs. Read current security guidance for your framework before deciding where the token lives in the browser.
Sources
This page is based on the official documentation below. Read it for full detail.
JWT — official documentation ↗