JavaScript JWT libraries

Updated Nov 2026

JavaScript JWT libraries create and verify JSON Web Tokens, the signed tokens that carry identity claims between services. A server checks each token's signature and claims, such as its issuer, audience, and expiry, before it trusts the payload. These libraries handle the login sessions, API authentication, and single sign-on in web apps and backend services.

Popularity

jose has the most monthly downloads in this comparison, at 878.5M.

LibraryMonthly downloadsStarsLast releaseLicense
jose
878.5M
7.9KNov 2026MIT
jsonwebtoken
317.9M
18.2KDec 2025MIT
Passport JWT
21.8M
2.0KDec 2022MIT
AWS JWT Verify
10.3M
751Jun 2026Apache-2.0
fast-jwt
7.3M
440Nov 2026Apache-2.0
Fastify JWT
5.3M
588Nov 2026MIT
express-jwt
4.4M
4.5KDec 2024MIT
Downloads: npm, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

Libraries and code examples

Signs, verifies, encrypts, and decrypts tokens across web-compatible JavaScript runtimes.

Downloads / mo
878.5M
Stars
7.9K
Last release
6.2.18
License
MIT

Strengths

  • Supports encrypted token payloads. Use EncryptJWT and jwtDecrypt for encrypted JWT workflows.
  • Loads remote verification key sets. createRemoteJWKSet fetches and caches keys from an HTTP endpoint.

Limitations

  • Algorithm availability varies by runtime. Check the chosen algorithm against the target runtime.
  • CommonJS needs compatible Node support. Use ESM or Node with require(esm) enabled.

Quickstart

From SignJWT.md
$ npm install jose@6.2.18
import { SignJWT, jwtVerify } from "jose";
const key = crypto.getRandomValues(new Uint8Array(32));
const token = await new SignJWT({ sub: "user-1" }).setProtectedHeader({ alg: "HS256" }).setExpirationTime("5m").sign(key);
const { payload } = await jwtVerify(token, key, { algorithms: ["HS256"] });
console.log(payload.sub);

jose examples

From open-source projects on GitHub

Signs JWTs and verifies signatures and configured token claims in Node.js.

Downloads / mo
317.9M
Stars
18.2K
Last release
9.0.3
License
MIT

Strengths

  • Supports synchronous and callback verification. Choose immediate results or callback-based verification.
  • Checks the intended token audience. Set audience and issuer during verification.

Limitations

  • Tokens need an explicit expiry. Set expiresIn or exp when tokens must expire.
  • Decoding alone skips signature verification. Use verify to validate an incoming token.

Quickstart

From README.md
$ npm install jsonwebtoken@9.0.3
const jwt = require("jsonwebtoken");
const { randomBytes } = require("node:crypto");
const key = randomBytes(32);
const token = jwt.sign({ sub: "user-1" }, key, { algorithm: "HS256", expiresIn: "5m" });
console.log(jwt.verify(token, key, { algorithms: ["HS256"] }));

jsonwebtoken examples

From open-source projects on GitHub

Authenticates endpoints through Passport with a JSON Web Token instead of a session.

Downloads / mo
21.8M
Stars
2.0K
Last release
4.0.1
License
MIT

Strengths

  • Session-free REST endpoints. Each request carries its own token rather than a server session.

Limitations

  • Token extraction is required. The jwtFromRequest option must name where each request carries its token.

Quickstart

From README.md
$ npm install passport-jwt@4.0.1 passport express
const express = require("express");
const passport = require("passport");
const { Strategy, ExtractJwt } = require("passport-jwt");
const secret = process.env.JWT_SECRET;
if (!secret) throw new Error("Set JWT_SECRET to the issuer shared key");
passport.use(new Strategy({ jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(), secretOrKey: secret, algorithms: ["HS256"] }, (claims, done) => done(null, claims)));
const app = express();
app.use(passport.initialize());
app.get("/me", passport.authenticate("jwt", { session: false }), (req, res) => res.json(req.user));
app.listen(3000);

Passport JWT examples

From open-source projects on GitHub

AWS JWT Verify

Verifies JWTs signed by Amazon Cognito, Application Load Balancer, or any OIDC-compatible identity provider.

Downloads / mo
10.3M
Stars
751
Last release
5.2.1
License
Apache-2.0

Strengths

  • Runs in browsers too. The verifier works in web browsers as well as Node.js.

Limitations

  • Verifies tokens only. It checks tokens that an identity provider issued rather than signing new ones.

Quickstart

From README.md
$ npm install aws-jwt-verify@5.2.1
import { CognitoJwtVerifier } from "aws-jwt-verify";
const verifier = CognitoJwtVerifier.create({ userPoolId: "us-east-1_EXAMPLE", tokenUse: "id", clientId: "YOUR_APP_CLIENT_ID" });
const claims = await verifier.verify("YOUR_ID_TOKEN");
console.log(claims.sub);

AWS JWT Verify examples

From open-source projects on GitHub

Builds reusable JWT signer, decoder, and verifier functions with optional verification caching.

Downloads / mo
7.3M
Stars
440
Last release
6.3.7
License
Apache-2.0

Strengths

  • Reuses configured verifier functions. Create a verifier once and pass tokens to it.
  • Caches verified tokens optionally. Enable cache to reuse prior verification results.

Limitations

  • Allowed algorithms need explicit restriction. Set algorithms to the expected signing algorithms.
  • Required claims need explicit configuration. Set requiredClaims for fields every token must contain.

Quickstart

From README.md
$ npm install fast-jwt@6.3.7
const { createSigner, createVerifier } = require("fast-jwt");
const { randomBytes } = require("node:crypto");
const key = randomBytes(32);
const sign = createSigner({ key, algorithm: "HS256", expiresIn: "5m" });
const verify = createVerifier({ key, algorithms: ["HS256"] });
console.log(verify(sign({ sub: "user-1" })));

fast-jwt examples

From open-source projects on GitHub

Adds sign, verify, and decode to a Fastify server, built on fast-jwt.

Downloads / mo
5.3M
Stars
588
Last release
10.2.8
License
MIT

Strengths

  • Request and reply helpers. The plugin registers request.jwtVerify and reply.jwtSign for route handlers.

Limitations

  • Secret required at registration. Registering the plugin requires a secret option.

Quickstart

From README.md
$ npm install @fastify/jwt@10.2.8 fastify@5
import Fastify from "fastify";
import jwt from "@fastify/jwt";
import { randomBytes } from "node:crypto";
const app = Fastify();
await app.register(jwt, { secret: randomBytes(32).toString("hex") });
console.log(app.jwt.sign({ sub: "user-1" }, { expiresIn: "5m" }));
await app.close();

Fastify JWT examples

From open-source projects on GitHub

express-jwt

Validates JWTs in Express middleware and places the decoded payload on the request.

Downloads / mo
4.4M
Stars
4.5K
Last release
8.5.1
License
MIT

Strengths

  • Reads the Authorization header. Tokens come from the Authorization header unless a custom getter is set.

Limitations

  • Algorithms must be listed. The required algorithms option guards against downgrade attacks.

Quickstart

From README.md
$ npm install express-jwt@8.5.1 express
const express = require("express");
const { expressjwt } = require("express-jwt");
const secret = process.env.JWT_SECRET;
if (!secret) throw new Error("Set JWT_SECRET to the issuer shared key");
const app = express();
app.get("/me", expressjwt({ secret, algorithms: ["HS256"] }), (req, res) => res.json(req.auth));
app.listen(3000);

FAQ

The decode function in jsonwebtoken returns a token's payload without checking its signature. Server code that trusts the payload calls verify instead.

A JWKS, or JSON Web Key Set, is a JSON document that publishes the public keys a token issuer signs with. jose creates a remote resolver that fetches missing or stale key sets, and AWS JWT Verify loads the key set from its jwksUri setting.

jsonwebtoken signs JWTs and verifies their signatures and configured claims in Node.js. It offers synchronous and callback forms of verify.

JWE, or JSON Web Encryption, is the token format for encrypted payloads. jose provides EncryptJWT and jwtDecrypt with claims validation.

jose signs, verifies, and encrypts tokens across web-compatible runtimes. jsonwebtoken signs and verifies tokens in Node.js.

A token carries an expiry only when the code sets expiresIn or an exp claim.

For coding agents

Found your JWT library? Help your agent use it.

Connect Exa so your coding agent can find the library’s documentation, check its API, and look up implementations while you build.

Run in your terminal

claude plugin install exa@claude-plugins-official