# jwt-decode **Repository Path**: mirrors/jwt-decode ## Basic Information - **Project Name**: jwt-decode - **Description**: Decode JWT tokens; useful for browser applications. - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2019-10-13 - **Last Updated**: 2026-01-31 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ![Browser library that helps decoding JWT tokens which are Base64Url encoded](https://cdn.auth0.com/website/sdks/banners/jwt-decode-banner.png) **IMPORTANT:** This library doesn't validate the token, any well-formed JWT can be decoded. You should validate the token in your server-side logic by using something like [express-jwt](https://github.com/auth0/express-jwt), [koa-jwt](https://github.com/stiang/koa-jwt), [Microsoft.AspNetCore.Authentication.JwtBearer](https://www.nuget.org/packages/Microsoft.AspNetCore.Authentication.JwtBearer), etc. ![Release](https://img.shields.io/npm/v/jwt-decode) ![Downloads](https://img.shields.io/npm/dw/jwt-decode) [![License](https://img.shields.io/:license-MIT-blue.svg?style=flat)](https://opensource.org/licenses/MIT) [![CircleCI](https://img.shields.io/circleci/build/github/auth0/jwt-decode)](https://circleci.com/gh/auth0/jwt-decode) :books: [Documentation](#documentation) - :rocket: [Getting Started](#getting-started) - :speech_balloon: [Feedback](#feedback) ## Documentation - [Docs site](https://www.auth0.com/docs) - explore our docs site and learn more about Auth0. ## Getting started ### Installation Install with NPM or Yarn. Run `npm install jwt-decode` or `yarn add jwt-decode` to install the library. ### Usage ```js import { jwtDecode } from "jwt-decode"; const token = "eyJ0eXAiO.../// jwt token"; const decoded = jwtDecode(token); console.log(decoded); /* prints: * { * foo: "bar", * exp: 1393286893, * iat: 1393268893 * } */ // decode header by passing in options (useful for when you need `kid` to verify a JWT): const decodedHeader = jwtDecode(token, { header: true }); console.log(decodedHeader); /* prints: * { * typ: "JWT", * alg: "HS256" * } */ ``` **Note:** A falsy or malformed token will throw an `InvalidTokenError` error; see below for more information on specific errors. ## Polyfilling atob This library relies on `atob()`, which is a global function available on [all modern browsers as well as every supported node environment](https://developer.mozilla.org/en-US/docs/Web/API/atob#browser_compatibility). In order to use `jwt-decode` in an environment that has no access to `atob()` (e.g. [React Native prior to version 0.74](https://github.com/facebook/hermes/issues/1178)), ensure to provide the corresponding polyfill in your application by using [`core-js/stable/atob`](https://www.npmjs.com/package/core-js): ```js import "core-js/stable/atob"; ``` Alternatively, you can also use [`base-64`](https://www.npmjs.com/package/base-64) and polyfill `global.atob` yourself: ```js import { decode } from "base-64"; global.atob = decode; ``` ## Errors This library works with valid JSON web tokens. The basic format of these token is ``` [part1].[part2].[part3] ``` All parts are supposed to be valid base64 (url) encoded json. Depending on the `{ header: