DEV Community

Sreekar Reddy
Sreekar Reddy

Posted on • Originally published at sreekarreddy.com

πŸ“œ JWT Explained Like You're 5

A signed badge with your ID

Day 8 of 149

πŸ‘‰ Full deep-dive with code examples


The Movie Theater Ticket

You buy a movie ticket at the counter.

The ticket has:

  • Movie name: "Spider-Man"
  • Time: 7:00 PM
  • Seat: B12
  • A special hologram so staff know it's real

You don't need to show your ID again. The ticket proves you paid!

JWT is a digital ticket for websites!


What JWT Stands For

JSON Web Token

  • JSON: A format for data
  • Web: Used on the internet
  • Token: A small piece of proof

What's Inside a JWT

Three parts, separated by dots:

eyJhbGciOiJIUzI1NiJ9.eyJuYW1lIjoiU3JlZWthciJ9.signature
        ↓                      ↓                    ↓
     Header                 Payload             Signature
  (how it's made)        (your info)       (proof it's real)
Enter fullscreen mode Exit fullscreen mode

Payload might contain:

  • Your user ID
  • Your name
  • When it expires

Signature = The hologram. It lets the server detect tampering.


How It Works

  1. You log in using a password
  2. Server creates a JWT with your info
  3. Server sends JWT to you
  4. You send JWT with every future request
  5. Server checks signature β†’ Trusts the info inside

In some designs, the server can verify the token without looking up a session record each time (though many systems still do lookups for permissions, revocation, or fresh user data).


In One Sentence

JWT is a signed, tamper-evident token format that can carry identity/authorization claims between a client and a server.

Note: A JWT is usually signed, not encrypted β€” so it shouldn't contain secrets.


πŸ”— Enjoying these? Follow for daily ELI5 explanations!

Making complex tech concepts simple, one day at a time.

Top comments (0)