What is jwt
Last updated: April 1, 2026
Key Facts
- JWT is defined by RFC 7519 and uses digital signatures to ensure the authenticity and integrity of transmitted data
- A JWT consists of three parts separated by dots: header (algorithm and token type), payload (claims), and signature (verification data)
- JWTs are stateless, meaning the server doesn't need to store session information, making them ideal for distributed systems and APIs
- Common use cases include user authentication, authorization, secure API communication, and single sign-on (SSO) across multiple applications
- JWTs can be verified without needing access to the original issuing server, using only the public key if signed with asymmetric algorithms
Overview
JWT (JSON Web Token) is an open standard (RFC 7519) that provides a method for securely transmitting claims between parties as a JSON object. The token is digitally signed and can be verified without access to a secret key, making it ideal for authentication and authorization in modern web applications and APIs. JWTs have become fundamental to contemporary security architecture, particularly in microservices and distributed systems.
JWT Structure
A JWT consists of three segments separated by periods: the header, payload, and signature. The header specifies the token type and the algorithm used for signing (e.g., HS256, RS256). The payload contains claims—statements about the entity and additional data. The signature is created by encoding the header and payload with a secret key, ensuring that the token hasn't been tampered with. The entire token is base64url encoded for URL-safe transmission.
Authentication and Authorization
JWTs are primarily used for authentication, allowing users to prove their identity without sending credentials repeatedly. After a user logs in, the server issues a JWT that the client includes in subsequent requests. For authorization, JWTs contain claims that specify what resources or actions a user is permitted to access. This approach is more efficient than traditional session-based authentication because the server doesn't need to query a database for each request.
Key Advantages
JWTs are stateless, meaning servers don't need to maintain session storage, reducing database load and improving scalability. They work seamlessly across different domains and are particularly useful in microservices architectures where services need to verify user identity independently. JWTs are language-agnostic and can be used across different technologies and platforms. They also enable single sign-on (SSO) functionality, allowing users to access multiple related applications with a single token.
Security Considerations
While JWTs provide strong security through digital signatures, proper implementation is critical. Tokens should include expiration times (exp claim) to limit the window of vulnerability if compromised. HTTPS should always be used to prevent token interception. Sensitive information should not be included in the payload since it's only encoded, not encrypted. Secret keys must be stored securely, and asymmetric algorithms (RS256) are recommended for distributed systems over symmetric algorithms (HS256).
Related Questions
How does JWT differ from OAuth?
JWT is a token format and encoding standard, while OAuth is an authorization framework. OAuth often uses JWTs as its token mechanism, but they serve different purposes in the authentication flow.
What are JWT claims?
Claims are statements about an entity included in the JWT payload. Examples include 'sub' (subject), 'iss' (issuer), 'aud' (audience), and custom claims containing user data.
How long should a JWT token be valid?
JWT expiration times vary by use case, typically ranging from 15 minutes to several hours. Shorter times improve security, while longer times reduce authentication overhead.
More What Is in Daily Life
Also in Daily Life
More "What Is" Questions
Trending on WhatAnswers
Browse by Topic
Browse by Question Type
Sources
- RFC 7519 - JSON Web Token (JWT)Public Domain
- Wikipedia - JSON Web TokenCC-BY-SA-4.0
- JWT.io - Introduction to JSON Web TokensMIT