MediumπŸ‘€ 3-5 yearsπŸ‘€ 8-15 years 1 min read

What is a JWT and how does it work?

Asked inAmazonDeloitte
Report issue

β˜•Coffee Chat Question

Concept Made Simple

β€œWhat is a JWT and how does it work?”

🧠Mind Map Answer

Remember It Faster

A JWT is a movie ticket 🎬. The cinema doesn't keep a list of who bought tickets β€” your stub already proves you paid, and the watermark (signature) proves it's not forged. The server stays stateless.

Header→algorithm & type
Payload→claims (user id, roles, exp)
Signature→verifies it was not tampered with

Format: header.payload.signature β€” three Base64 parts joined by dots.

⌨️Hands-on Keyboard

Learn by Doing

text
eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxMDEiLCJyb2xlIjoiYWRtaW4ifQ.S1g...
   ^header              ^payload                        ^signature

πŸ”₯What If?

Think Beyond the Expected

If the payload is just Base64, can anyone read it?

Yes β€” JWTs are signed, not encrypted. Never put secrets in the payload. The signature only guarantees integrity, not confidentiality.

πŸ˜‚Real World

After login your API returns a JWT; the frontend stores it and sends it in the Authorization header on every request. Each microservice verifies the signature locally β€” no shared session store, which is exactly why JWTs scale so well across services.

🎯Interviewer's Expectation

Keywords they're listening for:

βœ“ stateless authβœ“ header.payload.signatureβœ“ signed not encryptedβœ“ expiry (exp)βœ“ never store secrets in payload

Continue Learning with AI

Take this question deeper with your favourite AI assistant. Pick a depth, copy the prompt, or open it directly β€” AI is your learning companion, not a shortcut.

Plain-language foundations

I'm preparing for a software engineering interview and want to understand this from scratch, as a beginner.

Topic: Auth (REST APIs)
Interview question: "What is a JWT and how does it work?"

Please:
1. Explain the core idea in simple, plain language, using an everyday analogy.
2. Define any technical terms you use.
3. Walk through one small, concrete example.
4. Finish with a single sentence I can easily remember.

Keep the tone friendly and assume I'm new to this topic.

Was this answer helpful?

Support our platform by exploring our recommended products.

As an Amazon affiliate, purchases through these links may earn us a small commission β€” at no extra cost to you. It helps keep Full Stack Interview Guru free.

Related Questions