A JSON Web Token (JWT) is a compact, URL-safe token format defined in RFC 7519 that encodes a set of claims as a JSON object. It is commonly used as a bearer token in OAuth 2.0 and OpenID Connect (OIDC) flows to represent authorization grants. The token consists of three Base64Url-encoded parts—a header, a payload, and a signature—separated by dots, forming a structure suitable for stateless authentication.
Glossary
JWT (JSON Web Token)

What is JWT (JSON Web Token)?
A JSON Web Token is a compact, URL-safe token format defined in RFC 7519 that encodes a set of claims as a JSON object, which can be digitally signed using a JSON Web Signature (JWS) or encrypted using JSON Web Encryption (JWE).
JWTs are either signed using a JSON Web Signature (JWS) with algorithms like HMAC or RSA to ensure integrity, or encrypted via JSON Web Encryption (JWE) for confidentiality. The payload contains registered claims (e.g., iss, exp, sub) and custom data. Resource servers validate the token's signature and claims without querying the authorization server, enabling scalable, stateless API authentication for machine-to-machine and user-agent scenarios.
Key Characteristics of JWT
A JSON Web Token (JWT) is a compact, URL-safe token format that encodes a set of claims as a JSON object, which can be digitally signed or encrypted. Its design enables stateless, verifiable authentication and authorization for APIs and distributed systems.
Compact & Self-Contained Structure
A JWT is a compact string consisting of three Base64Url-encoded segments separated by dots (.): Header.Payload.Signature. This structure is self-contained, meaning the payload carries all necessary claims (user identity, scopes, issuer) required for authorization, eliminating the need for the resource server to query a database or authorization server for each request. This enables efficient, stateless API design.
- Header: Contains metadata like the token type (
JWT) and the signing algorithm (e.g.,HS256,RS256). - Payload: Contains the claims—statements about an entity (e.g., user) and additional data. Standard claims include
iss(issuer),exp(expiration time),sub(subject). - Signature: Created by signing the encoded header and payload with a secret or private key, ensuring the token's integrity.
Stateless Verification via Digital Signature
The core security of a JWT lies in its digital signature (or Message Authentication Code for symmetric keys). The signature is generated using the algorithm specified in the header (e.g., HMAC SHA256, RSA SHA256). When a resource server receives a JWT, it can independently verify the signature using the appropriate key (a shared secret or the authorization server's public key). Successful verification proves:
- Integrity: The token has not been tampered with after issuance.
- Authenticity: The token was issued by a trusted party possessing the correct signing key.
This stateless verification allows scalable, distributed architectures where any service with the correct key can validate the token without coordinating with a central auth server.
Standardized Claims & Extensibility
JWTs use a standardized set of registered claim names defined in RFC 7519 for interoperability, while allowing custom claims for application-specific data.
Common Registered Claims:
iss(Issuer): Identifies the principal that issued the JWT.sub(Subject): Identifies the principal that is the subject of the JWT.aud(Audience): Identifies the recipients that the JWT is intended for.exp(Expiration Time): Identifies the expiration time on or after which the JWT MUST NOT be accepted.iat(Issued At): Identifies the time at which the JWT was issued.
Custom Claims: Applications can define their own claims (e.g., user_role, permissions, tenant_id) to embed authorization context directly within the token. This flexibility makes JWTs adaptable to complex authorization models like Role-Based Access Control (RBAC) or custom attribute-based systems.
JWS vs. JWE: Signed vs. Encrypted Tokens
JWTs come in two primary security forms, defined by separate RFCs:
-
JSON Web Signature (JWS) - RFC 7515: A signed JWT. The payload is Base64Url encoded but not encrypted, meaning its contents are readable by anyone who possesses the token. The signature ensures integrity and authenticity. This is the most common form, used for access tokens where the claims need to be read by the client or intermediate gateways.
-
JSON Web Encryption (JWE) - RFC 7516: An encrypted JWT. The payload is encrypted, making the claims confidential. Only parties with the correct decryption key can read the contents. JWE is used when token contents are highly sensitive and must not be exposed to the client (e.g., tokens passed through an untrusted browser).
Most API authentication uses JWS, as the payload typically contains non-sensitive authorization context needed by the resource server.
Common Use Cases in API Security
JWTs are a foundational technology in modern API authentication and authorization flows, particularly within the OAuth 2.0 and OpenID Connect (OIDC) ecosystems.
Primary Applications:
- OAuth 2.0 Access Tokens: JWTs are commonly used as structured, self-contained access tokens, allowing resource servers to validate scopes and user context without a network call.
- OpenID Connect ID Tokens: In OIDC, the ID Token is always a JWT. It contains claims about the authentication event and user profile, which the client uses to verify the user's identity.
- Session Management: JWTs can replace traditional server-side sessions in stateless web applications (e.g., Single Page Applications). The token is stored client-side (often in an HTTP-only cookie for security) and sent with each request.
- Service-to-Service (M2M) Communication: In the OAuth 2.0 Client Credentials flow, JWTs can be used as client assertion tokens for authenticating the client to the authorization server.
Critical Security Considerations
While powerful, JWTs require careful implementation to avoid security pitfalls.
Key Risks and Mitigations:
- Algorithm Confusion ("alg": "none"): Attackers may try to strip or alter the signature. Mitigation: Always explicitly validate the signing algorithm on the server and reject tokens with
"none"or unexpected algorithms. - Token Storage: JWTs stored in browser
localStorageare vulnerable to XSS attacks. Prefer secure, HTTP-only cookies for web apps, though this introduces CSRF concerns that must be addressed. - Token Expiry: JWTs are valid until their
expclaim. Use short-lived access tokens (minutes) paired with long-lived refresh tokens (secured server-side) to balance security and usability. - Logout/Revocation Challenges: Because JWTs are stateless, they cannot be individually revoked before expiration. Mitigations include using very short token lifetimes, maintaining a small token blocklist, or using token introspection (RFC 7662) for active validation.
- Sensitive Data in Payload: Avoid placing sensitive data (e.g., passwords, full PII) in an unencrypted (JWS) token payload. Use JWE for confidentiality.
How JWT Works: Structure and Validation
A JSON Web Token (JWT) is a compact, URL-safe token format defined in RFC 7519 that encodes a set of claims as a JSON object, which can be digitally signed using a JSON Web Signature (JWS) or encrypted using JSON Web Encryption (JWE).
A JWT consists of three Base64Url-encoded segments separated by dots: the Header, Payload, and Signature. The Header specifies the token type and signing algorithm (e.g., HS256 or RS256). The Payload contains the claims—statements about an entity and additional metadata, such as the issuer (iss), subject (sub), and expiration time (exp). The Signature is generated by signing the encoded header and payload with a secret or private key, ensuring the token's integrity.
Validation involves verifying the Signature using the appropriate public key or shared secret to confirm the token's authenticity and that it hasn't been tampered with. The client must also check standard claims like expiration and the issuer to ensure the token is valid for the current context and intended audience. This stateless design makes JWTs ideal for distributed systems and API authentication, as the resource server can validate tokens without querying the authorization server for each request.
Frequently Asked Questions
A JSON Web Token (JWT) is a compact, URL-safe token format defined in RFC 7519 that encodes a set of claims as a JSON object, which can be digitally signed using a JSON Web Signature (JWS) or encrypted using JSON Web Encryption (JWE). This FAQ addresses common technical questions for developers and architects implementing authentication and authorization flows.
A JSON Web Token (JWT) is a compact, URL-safe token format defined in RFC 7519 that encodes a set of claims as a JSON object, which can be digitally signed using a JSON Web Signature (JWS) or encrypted using JSON Web Encryption (JWE). It works by transmitting a structured payload between parties as a string composed of three Base64Url-encoded segments separated by dots: the Header, the Payload, and the Signature. The Header specifies the token type and signing algorithm (e.g., {"alg": "RS256", "typ": "JWT"}). The Payload contains the claims—statements about an entity (like a user) and additional metadata (e.g., iss for issuer, exp for expiration). The Signature is generated by signing the encoded header and payload with a secret or private key, ensuring the token's integrity and, in the case of asymmetric cryptography, its authenticity. The recipient validates the signature to verify the token was issued by a trusted party and has not been tampered with.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
JSON Web Tokens (JWT) are a core component of modern API security, but they operate within a broader ecosystem of standards and protocols. Understanding these related concepts is essential for designing secure authentication and authorization systems for AI agents and backend services.

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us