What is a JSON Web Token (JWT) and How Does It Work?
JSON Web Token (JWT) is an open, industry-standard specification (RFC 7519) for securely transmitting information between two parties as a compact, URL-safe JSON object. JWTs are widely utilized in modern web engineering for stateless session authentication, Single Sign-On (SSO), and microservices authorization.
Because tokens are cryptographically signed using either a symmetric secret key (such as HMAC SHA-256) or an asymmetric public/private keypair (such as RSA or ECDSA), the receiving backend server can verify that the claims inside the token have not been tampered with by unauthorized third parties.
Anatomy of a JSON Web Token: The Three Parts
A standard JWT string is composed of three distinct Base64URL-encoded segments separated by dots (.):
Header
Specifies the token type (JWT) and the cryptographic signing algorithm used, such as HS256 or RS256.
Payload
Contains the session claims, user identifiers (sub), role permissions, and token lifecycle timestamps (iat, exp).
Signature
Calculated by hashing the encoded header, encoded payload, and your application's private secret key together to ensure integrity.
Standard Registered Claims Reference (RFC 7519)
While custom claims can store arbitrary user attributes, RFC 7519 defines reserved claims for interoperability:
| Claim | Full Name | Type | Description |
|---|---|---|---|
| iss | Issuer | String / URL | Identifies the principal that issued the JWT (e.g. https://auth0.com). |
| sub | Subject | String | Identifies the principal subject of the token (commonly the unique User ID). |
| aud | Audience | String / Array | Identifies the target recipients or microservices that accept the token. |
| exp | Expiration Time | Numeric (Seconds) | Unix epoch timestamp on or after which the JWT must NOT be accepted. |
| iat | Issued At | Numeric (Seconds) | Unix timestamp indicating when the token was minted. |
A common developer pitfall is assuming JWTs conceal or encrypt data. JWT tokens are signed, not encrypted (unless using JWE - JSON Web Encryption). Anyone with access to the token string can decode the payload instantly using Base64URL decoders like this tool.Never store unencrypted passwords, credit card numbers, or proprietary API secrets inside a standard JWT payload.
Inspecting production tokens on unauthorized third-party websites can expose session identifiers to server access logs or external analytics. DevToolbox executes all JWT string splitting, Base64URL parsing, and JSON rendering strictly on your local device. No tokens or authorization headers are ever logged or transmitted across the internet.
Frequently Asked Questions (FAQ)
Does decoding a JWT verify its cryptographic signature?
No. Decoding simply translates the Base64URL-encoded strings into human-readable JSON objects. Signature verification requires calculating the cryptographic hash with the private secret key or public certificate, which should always take place on your secure backend server.
Where is the best place to store JWTs on the client?
For web applications, the most secure storage mechanism is an HttpOnly, Secure, and SameSite cookie. Storing sensitive authentication tokens in localStorage leaves them vulnerable to Cross-Site Scripting (XSS) extraction attacks.
Why does my JWT have three parts instead of two?
The three parts represent the Header, Payload, and Signature. While an unsigned token (algorithm none) can technically exist, secure production JWT implementations always require the third signature component to prevent claim falsification.