The Software Engineer's Guide to JSON Web Tokens (JWT)
JSON Web Tokens (JWT) specified under RFC 7519 serve as the foundation of modern stateless authentication across microservices, RESTful APIs, and single-page applications (SPAs).
1. Anatomical Breakdown of a JWT Token
A standard JWT string consists of three distinct Base64Url-encoded segments separated by periods (`.`):
- Header (Red): Declares the signing algorithm (e.g. `HS256`, `RS256`) and token type (`JWT`).
- Payload (Purple): Contains registered claims (such as `sub`, `iss`, `exp`, `iat`) alongside custom application user roles and permission scopes.
- Signature: Cryptographic hash constructed by combining the encoded header, payload, and a secret key to prevent payload tampering.
2. Essential Registered Claims for API Security
Implementing registered claim parameters ensures robust session management:
| Claim Key | Claim Name | Example Value | Security Purpose |
|---|---|---|---|
iss |
Issuer | "https://auth.example.com" |
Identifies the security server that generated and signed the token. |
sub |
Subject | "usr_98a71f02" |
Represents the principal entity or user identity authenticated by the token. |
aud |
Audience | "https://api.example.com/v1" |
Restricts which recipient resource servers may process the token. |
exp |
Expiration Time | 1773829200 |
Unix epoch timestamp after which the token must be rejected by APIs. |
nbf |
Not Before | 1773825600 |
Declares the earliest timestamp at which the token becomes valid. |
iat |
Issued At | 1773825600 |
Identifies when the token was created, useful for calculating token age. |
3. Why Client-Side JWT Parsing Protects Privacy
Decoding authorization tokens in the browser ensures that sensitive user claims and session IDs are never logged by middleman proxy servers. Our tool executes 100% locally using native JavaScript Base64Url decoding.