jsonwebtoken

The de facto Node.js library for signing, verifying, and decoding JSON Web Tokens.

Library
npm
v9.0.3
18,177 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
47 /100 Fair
Development Activity 12
Maintenance 0
Community 76
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
78 /100 Good
Architecture 78
Code Quality 85
Innovation 72
Learning Curve 75

jsonwebtoken is the most widely used Node.js implementation of the JSON Web Token (JWT) standard (RFC 7519), providing simple sign, verify, and decode functions for issuing and validating tokens. It supports HMAC (HS256/384/512), RSA (RS256/384/512), RSA-PSS (PS256/384/512), and ECDSA (ES256/384/512) algorithms, plus claim validation for expiration, audience, issuer, subject, and not-before.

Maintained by Auth0 and used across countless authentication and API-authorization flows, the library exposes both synchronous and callback-based asynchronous APIs, ships built-in protections against algorithm-confusion attacks, and keeps its dependency surface to a handful of small, focused helper packages.

What You Get

  • jwt.sign() for creating tokens synchronously or via callback, with support for HMAC, RSA, RSA-PSS, and ECDSA algorithms
  • jwt.verify() for validating signature, expiration (exp), not-before (nbf), audience, issuer, subject, and JWT ID claims in one call
  • jwt.decode() for reading a token’s payload/header without verifying its signature
  • Built-in algorithm allowlisting to guard against algorithm-confusion/downgrade attacks
  • Typed error classes (JsonWebTokenError, TokenExpiredError, NotBeforeError) for precise failure handling

Common Use Cases

  • Issuing session tokens for stateless API authentication
  • Signing and verifying access/refresh tokens in an OAuth2 or OpenID Connect flow
  • Generating short-lived tokens for password-reset or email-verification links
  • Validating service-to-service tokens signed with RSA/ECDSA key pairs

Under The Hood

Architecture — The package is a thin, function-oriented wrapper rather than a class hierarchy: sign.js (253 lines), verify.js (263 lines), and decode.js (30 lines) sit at the repo root as the three public entry points, each importing shared validators from lib/ (validateAsymmetricKey.js, timespan.js, psSupported.js) and three typed error classes (JsonWebTokenError, NotBeforeError, TokenExpiredError). index.js simply re-exports these five symbols, so the whole module surface is deliberately small and traceable end-to-end from a single file per operation.

Tech Stack — Pure JavaScript (CommonJS, no TypeScript source) targeting Node >=12. Runtime dependencies are minimal and split into single-purpose micro-packages (lodash.includes, lodash.isboolean, lodash.isinteger, lodash.isnumber, lodash.isplainobject, lodash.isstring, lodash.once instead of full lodash), plus jws for the underlying signature format, ms for human-readable time spans, and semver for internal version checks. Node’s built-in crypto module (KeyObject, createSecretKey, createPrivateKey) is used directly for key handling rather than a third-party crypto wrapper.

Code Quality — The project enforces strict coverage via nyc (95% lines/statements/branches, 100% functions) and ships 34 test files under test/ covering claim-by-claim behavior (claim-aud, claim-exp, claim-iat, claim-iss, claim-jti, claim-nbf, plus dedicated encoding, decoding, and async-sign suites) using mocha, chai, and sinon. ESLint and Husky pre-commit hooks are configured, and semantic-release/commitlint enforce conventional commits, indicating a mature, process-driven maintenance workflow for a small codebase.

API Design — The public API is deliberately minimal: three top-level functions (sign, verify, decode) each accepting a plain options object, with every function usable either synchronously (return value or thrown error) or asynchronously (Node-style callback). Options schemas (sign_options_schema, registered_claims_schema) are validated defensively with descriptive error messages before any cryptographic work happens, and verify() requires an explicit algorithms allowlist — a deliberate ergonomic trade-off that adds one required option in exchange for closing a well-known JWT vulnerability class.

Used by 93 apps in this directory

TypeScript
97%
Other

Lightdash

Analytics · Data Engineering

6,196

The open-source Looker alternative that turns your dbt project's metrics and dimensions into governed, self-serve charts and dashboards — no license key required.

View details
93
Repo Health
84
Technical
64
Dependency
Built with
TypeScript 97%
Updated 6 days ago
TypeScript
71%
Other

LogChimp

Marketing · Product Management

1,132

Collect customer feedback, prioritize features with upvotes, and build transparent product roadmaps — fully self-hosted and open source.

View details
83
Repo Health
77
Technical
72
Dependency
Built with
TypeScript 71%
Vue 27%
Updated 1 weeks ago
TypeScript
99%
Apache 2.0

Mastra Code

AI Code Assistants

29,041

"A coding agent that never compacts" — a terminal-based AI coding agent built on the Mastra framework, with Observational Memory instead of context compaction, multi-model support, and OAuth login for Claude Max or ChatGPT Plus.

View details
90
Repo Health
73
Technical
65
Dependency
Built with
TypeScript 99%
Updated 6 days ago
TypeScript
87%
MIT

medusa

Ecommerce

36,897

The most flexible open-source commerce platform — build B2C, B2B, and marketplace applications with modular, composable commerce primitives.

View details
94
Repo Health
87
Technical
63
Dependency
Built with
TypeScript 87%
JavaScript 12%
Updated 1 weeks ago
TypeScript
53%
MIT

MentraOS

AI Development · Developer Tools

2,391

The open source operating system and SDK that lets developers build one app and run it across smart glasses from Even Realities, Vuzix, Mentra Live, and more.

View details
92
Repo Health
77
Technical
66
Dependency
Built with
TypeScript 53%
Java 16%
Updated 6 days ago
Clojure
57%
Other

Metabase

Analytics

49,827

The open-source BI platform that lets anyone ask questions and build dashboards without writing SQL — with an embedded analytics SDK and AI-powered query assistant included.

View details
95
Repo Health
84
Technical
62
Dependency
Built with
Clojure 57%
TypeScript 38%
Updated 6 days ago
JavaScript
94%
AGPL 3.0

MyApi

AI Agents

23

A privacy-first personal API gateway for AI agents — connect your services once, issue scoped tokens to agents like OpenClaw, Hermes, or Claude Code, and keep a full audit trail instead of scattering raw credentials across .env files.

View details
37
Repo Health
64
Technical
73
Dependency
Built with
JavaScript 94%
Updated 3 weeks ago
TypeScript
92%
Other

n8n

Automation · No Code Platforms

208,437

Code when you need it, UI when you don't — the workflow automation platform built for technical teams who refuse to choose.

View details
95
Repo Health
87
Technical
62
Dependency
Built with
TypeScript 92%
Updated 1 weeks ago
TypeScript
97%
Other

nango

Authentication · Automation · Developer Tools

12,963

Build product integrations with AI using 800+ APIs — auth, proxy, and TypeScript functions on production-grade infrastructure.

View details
94
Repo Health
85
Technical
67
Dependency
Built with
TypeScript 97%
Updated 1 weeks ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers