DEV Community

Cover image for Decode JWT Token easily using _jwt-decode_
Nodirbek-Abdulaxadov
Nodirbek-Abdulaxadov

Posted on

1 1 1 1 1

Decode JWT Token easily using _jwt-decode_

  1. Install with NPM or Yarn
npm install jwt-decode
//or
yarn add jwt-decode
Enter fullscreen mode Exit fullscreen mode
  1. Import package:
import { jwtDecode } from "jwt-decode";
Enter fullscreen mode Exit fullscreen mode
  1. Usage
const token = "eyJ0eXAiO.../// jwt token";
// Returns with the JwtPayload type or any type
// const decodedJwt = jwtDecode<JwtPayload>(token);
const decodedJwt: any = jwtDecode(token);

//example print expiration date
console.log(decodedJwt.exp);
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay