Developer Tools

JWT for Beginners: How JSON Web Tokens Actually Work

📅 Published June 17, 2026 🕒 Last Updated: July 2026 ⏱ 10 min read ✍️ Rashid Amin, Founder of NexaTools

If you have started working with login systems, APIs, or any kind of user authentication, you have almost certainly run into the term JWT. It shows up in tutorials, framework documentation, and error messages, often without much explanation of what it actually is. This guide breaks it down from the ground up, with no assumed prior knowledge of tokens or cryptography.

By the end, you will understand what a JWT actually contains, why it is structured the way it is, and how to inspect one yourself using the free NexaTools JWT Decoder.

What Problem Does a JWT Solve?

Websites need a way to remember that you are logged in as you move between pages, since each request to a server is otherwise independent and stateless. Historically, this was solved with session identifiers stored server-side, but as applications grew into distributed systems with multiple servers and services, checking a central session store on every request became a bottleneck. A JWT solves this differently: instead of the server looking up your session, the token itself carries the information needed to confirm who you are, cryptographically signed so it cannot be tampered with along the way.

Breaking Down the Name

JSON Web Token. It is called that because the data inside it is formatted as JSON, and it is designed specifically to be passed around the web, most commonly inside an HTTP header or a cookie. Once you know it is just structured, signed JSON, the rest of the concept becomes much less intimidating.

The Three Parts of Every JWT

Every JWT is a single string made of three sections separated by periods. Written out, it looks something like header.payload.signature. Each section serves a distinct purpose.

1. Header
A small JSON object describing the token itself, most importantly which algorithm was used to sign it, such as HS256. This section is Base64 URL-encoded, not encrypted.
2. Payload
The actual data, called claims, such as a user ID, an expiration timestamp, or custom fields like a role or permission level. This is also just Base64 URL-encoded JSON, readable by anyone who has the token.
3. Signature
A cryptographic value created by combining the header, the payload, and a secret key known only to the server. This is what makes the token tamper-evident.
✦ The Most Common Beginner Misconception
A JWT is not encrypted. The header and payload are only encoded, meaning anyone who has the token can read every field inside it without needing any secret. What the signature protects against is tampering, not visibility. Never put highly sensitive data like a raw password inside a JWT payload.

How a Server Actually Verifies a JWT

When a server receives a JWT, it does not trust the payload blindly. It recomputes the signature using the header, the payload, and its own secret key, then compares that result to the signature included in the token. If they match, the server can be confident the token has not been altered since it was issued if a single character in the header or payload changed, the recomputed signature would come out completely different, and the token would be rejected.

What a Typical Payload Looks Like

Once decoded, a JWT payload is just a JSON object. A simple example might include a subject field identifying the user, an issued-at timestamp, an expiration timestamp, and whatever custom claims the application needs, like a role or account tier. There is no fixed list of required fields beyond a small set of common conventions applications are free to include whatever claims make sense for their own authorization logic.

Reading Expiration Correctly

The expiration claim, commonly labeled exp, is a Unix timestamp representing a specific point in time. If that time has already passed relative to the current moment, most systems will reject the token even though it decodes and reads just fine. This is one of the single most common causes of confusing "unauthorized" errors during development a token that looks completely valid when decoded but has simply expired.

Why Developers Decode JWTs During Debugging

How to Decode a JWT with NexaTools

  1. Open the NexaTools JWT Decoder from the Tools section
  2. Paste the complete token string, including all three sections
  3. The header and payload are instantly decoded and displayed as readable JSON
  4. Check the expiration timestamp and claims to diagnose the issue you're debugging

If you want to understand the underlying encoding format a JWT's header and payload actually use, it comes down to a specific URL-safe variant of Base64 designed so tokens can be passed in URLs and headers without escaping special characters.

A Note on Handling Real Tokens Safely

Because a JWT payload is readable by anyone who has the string, treat real production tokens the same way you would treat a password or API key. Avoid pasting live tokens into tools you do not trust, and prefer using test tokens from a development environment whenever you are just trying to understand the format rather than debug a specific live issue.

Frequently Asked Questions

Is a JWT the same as an API key?

No. An API key is typically a static, opaque string with no embedded data. A JWT carries structured, readable claims and has a built-in expiration mechanism, making it better suited for representing a temporary, verifiable identity.

Can anyone read the contents of my JWT?

Yes, anyone with the token string can decode and read the header and payload, since they are only Base64 encoded, not encrypted. Never store highly sensitive data directly in a JWT payload.

What happens when a JWT expires?

The token itself does not disappear it will still decode successfully. However, a properly configured server should reject it once the current time is past the expiration claim, requiring the user to log in again or refresh their token.

Do I need to understand cryptography to use JWTs?

No. Most frameworks and libraries handle signing and verification internally. Understanding the three-part structure and the difference between encoding and encryption is generally enough for day-to-day debugging.

🛠️ Decode a JWT Free

No signup, no limits. Paste any token and instantly see its header and payload.

⚡ Open JWT Decoder

Reviewed by Rashid Amin

Founder of NexaTools

Rashid Amin is the founder of NexaTools, a platform dedicated to building fast, privacy-first online tools for PDFs, images, developers, AI, resume creation, and business workflows.

Last Updated: July 2026