Skip to content
BENIBIX Learn

JSON Web Token (JWT)

Development🔑 AuthSessions and Tokens

Also known as JWT, JWTs, jot

A signed token in three parts. It carries facts about a user.

Think of it like

Think of it like a sealed note. Anyone can read it, but a broken seal shows it was changed.

Example

Lucy's API reads the JWT on each request. The payload says user 42, expires at 1 January 2026, and the valid signature means it can be trusted.

Why it matters

A server can check a JWT without asking a database. That helps when many servers share the work.

Definition

A JSON Web Token is a small, signed token that carries facts about a user. It has three parts joined by dots: a header, a payload of facts and a signature. The payload might say the user's ID and when the token runs out. The server checks the signature, so it can trust the facts without looking them up. The payload is only encoded, not hidden, so it must never hold secrets.

Example code

json
{
  "sub": "42",
  "name": "Lucy",
  "exp": 1767225600
}
The payload: user 42, and exp is midnight on 1 January 2026 in UTC.

Common mistake

Putting private data in the payload. Anyone can read it in seconds; the signature only stops changes.

Key takeaways

  1. 1
    Three parts. Header, payload, signature.
  2. 2
    Signed, not hidden. Readable by anyone.
  3. 3
    Checked without lookup. The signature is the proof.

Compare