PACKAGE · AUTHENTICATION

jwt-decode

Decode JWT tokens, mostly useful for browser applications.

WEEKLY DOWNLOADS 7.6M
STARS 3.4K
FORKS 343
OPEN ISSUES 10
GZIP SIZE 500 B
UNPACKED SIZE 13.9 kB
LAST UPDATED 2mo ago
DOWNLOAD TRENDS

jwt-decode downloads — last 12 months

Download trends for jwt-decode1 download series from Jun 2025 to May 2026. Use left and right arrow keys to inspect monthly values.016.2M32.4M48.6M64.8MJun 2025SepDecMarMay 2026
jwt-decode
ABOUT JWT-DECODE

jwt-decode is a small, fast JavaScript library designed specifically for decoding JSON Web Tokens (JWTs). It addresses the common need in client-side applications to inspect the payload of a JWT without the overhead of cryptographic verification, which is typically handled by a backend service. The primary problem it solves is granting developers access to the claims within a token, such as user identity, roles, or expiration times, making this information readily available for UI rendering or client-side logic.

This package prioritizes a minimal footprint and straightforward API, making it ideal for frontend developers working in browser environments. Its design goal is to provide a quick and efficient way to parse token contents, assuming the token's authenticity has already been validated by a trusted source. The library is not concerned with token creation or signature verification, focusing solely on the decoding aspect.

At its core, jwt-decode offers a single `jwtDecode` function. This function accepts the JWT string as input and returns a JavaScript object representing the decoded payload. Developers typically pass the token string obtained after successful authentication to this function. There are no complex configuration options or lifecycle management, ensuring a simple integration.

The library integrates seamlessly into typical frontend build workflows. It's commonly used in conjunction with authentication libraries or custom authentication flows where JWTs are the chosen method for state management. Its small bundle size and lack of external dependencies make it a suitable choice for frontend frameworks and vanilla JavaScript applications alike.

With a gzipped bundle size of only 500 B, jwt-decode has a negligible impact on application load times. Its performance is optimized for rapid parsing, allowing developers to access token claims almost instantaneously. The library is mature, with version 4.0.0 indicating ongoing maintenance, and its extensive weekly download count of 13.9M suggests widespread adoption and reliability.

It's crucial to remember that jwt-decode does not perform any validation of the token's signature or expiration. Developers must implement separate mechanisms for verifying the token's integrity and ensuring it has not expired before trusting the decoded content. Relying solely on jwt-decode for security-sensitive decisions without accompanying validation can lead to vulnerabilities.

WHEN TO USE
  • When accessing user information or roles stored in a JWT payload for display in a client-side application.
  • When integrating with an authentication service that issues JWTs and requires immediate client-side access to claims.
  • When needing to display token expiration times or other metadata to the user within the UI.
  • When optimizing frontend bundle size, as the 500 B (gzip) package size is minimal.
  • When working with existing JWTs where server-side validation has already been completed before the token reaches the client.
  • When building single-page applications (SPAs) that manage user sessions via JWTs.
WHEN NOT TO USE
  • If the primary requirement is to verify the JWT's signature to ensure its authenticity; use a dedicated JWT verification library or backend service instead.
  • If the JWT needs to be validated for expiration or other standard claims before being consumed; implement separate validation logic.
  • If building a backend service that is responsible for issuing and validating JWTs; verification should occur server-side.
  • If the application primarily deals with session cookies and does not utilize JWTs for authentication.
  • If you require synchronous decoding without any asynchronous operations, as there are no explicit asynchronous patterns in this library, but it's good to be clear that this is synchronous by design.

CORRECTIONS

Spot wrong data here?

A short note helps us fix it.

Anonymous · No account · No email back

COMPARISONS 7
jwt-decode vs @supabase/supabase-js ★ 4.5K · 10.8M/wk jwt-decode vs jose ★ 7.6K · 40.1M/wk jwt-decode vs @auth0/nextjs-auth0 ★ 2.3K · 281.4K/wk jwt-decode vs @clerk/nextjs ★ 1.7K · 785.1K/wk jwt-decode vs @auth/core ★ 28.3K · 1.8M/wk jwt-decode vs lucia ★ 10.5K · 106.1K/wk jwt-decode vs next-auth ★ 28.3K · 2.4M/wk