jsonwebtoken

Create and decode JSON Web Tokens in Rust in a strongly typed way

Library
Cargo
v11.0.0
2,086stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
64/100Good
Development Activity60
Maintenance28
Community68
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
80/100Excellent
Architecture82
Code Quality85
Innovation78
Learning Curve75

jsonwebtoken is a Rust library for encoding and decoding JSON Web Tokens (JWTs), covering the full range of common signing algorithms — HMAC (HS256/384/512), RSA (RS/PS 256/384/512), and elliptic-curve (ES256/384, EdDSA) — with claims modeled as ordinary strongly-typed Rust structs via serde, rather than loosely-typed maps.

A distinguishing design choice is its pluggable crypto backend: consumers select either the aws_lc_rs or rust_crypto feature (or supply their own CryptoProvider), letting the library be used in environments with different cryptography requirements — including FIPS-adjacent deployments — without forking the crate itself. It also includes JWK (JSON Web Key) support for working with key sets published by identity providers.

What You Get

  • encode()/decode() functions operating on any Serialize/Deserialize claims struct instead of untyped JSON maps
  • Support for HS256/384/512, RS256/384/512, PS256/384/512, ES256/384, and EdDSA signing algorithms
  • EncodingKey/DecodingKey types for loading keys from PEM, DER, secrets, or raw components
  • A Validation struct for configuring expiry (exp), audience, issuer, and other standard-claim checks during decode
  • JWK (jwk.rs) support for parsing and working with published JSON Web Key Sets from identity providers
  • Swappable crypto backends (aws_lc_rs or rust_crypto feature, or a caller-supplied CryptoProvider) instead of one hardcoded implementation

Common Use Cases

  • Issuing and validating access/refresh tokens for a Rust web API’s authentication layer
  • Verifying tokens issued by external identity providers (Auth0, Okta, AWS Cognito) using their published JWKS
  • Building service-to-service auth where tokens carry strongly-typed custom claims (roles, tenant IDs, scopes)
  • Deploying in regulated environments that require a specific cryptography backend (e.g. FIPS-validated) via the pluggable CryptoProvider
  • Signing and verifying tokens with asymmetric keys (RSA/EC) for scenarios where the issuer and verifier are different services

Under The Hood

Architecture — The crate is organized around a small set of focused modules: encoding.rs/decoding.rs implement the top-level encode/decode entry points, header.rs models the JWT header (algorithm + type), validation.rs (~850 lines) implements claim validation (expiry, audience, issuer, leeway), jwk.rs (~850 lines) implements JSON Web Key parsing, and crypto/ plus pem/ house the per-algorithm signing/verification implementations and PEM key parsing. algorithms.rs defines the Algorithm enum that ties a JWT header’s alg field to the correct crypto backend call.

Tech Stack — Pure Rust (edition 2024, MSRV 1.88), built on serde/serde_json for claims serialization, base64 for JWT segment encoding, and the signature crate as a common trait for pluggable signing backends. Rather than hardcoding one crypto library, it depends on either aws_lc_rs or rust_crypto behind a Cargo feature flag, or accepts a caller-supplied CryptoProvider implementing the signature trait — a design that decouples the JWT logic from any single cryptography implementation.

Code Quality — Tests are organized per-algorithm-family under tests/ (hmac.rs, rsa/, ecdsa/, eddsa/, plus a dangerous.rs suite explicitly testing insecure/edge-case configurations like alg: none rejection), with benches/ for performance regression tracking. The crate is widely depended upon (150M+ cumulative downloads) and has a documented CHANGELOG tracking breaking changes across major versions, reflecting the care warranted by a security-sensitive library.

API Designencode(&header, &claims, &encoding_key) and decode::<Claims>(&token, &decoding_key, &validation) are the only two calls most consumers need, with claims expressed as ordinary Rust structs deriving Serialize/Deserialize rather than stringly-typed maps — misspelled or missing claim fields become compile errors instead of runtime surprises. The Validation builder pattern for configuring expected audience/issuer/leeway keeps common security checks explicit and discoverable rather than buried in decode-time flags.

Used by 13 apps in this directory

TypeScript
89%
Other

FastGPT

AI Agents · AI Development

29,387

Build, debug, and deploy knowledge-based AI agents with a visual workflow editor, RAG retrieval, and support for any OpenAI-compatible LLM.

View details
93
Repo Health
84
Technical
70
Dependency
Built with
TypeScript89%
Updated today
TypeScript
69%
Apache 2.0

Laminar

AI Development · Monitoring

3,180

Open-source observability platform purpose-built for AI agents — trace, evaluate, debug, and monitor at scale with SQL access and real-time replay.

View details
85
Repo Health
76
Technical
70
Dependency
Built with
TypeScript69%
Rust29%
Updated yesterday
Rust
78%
AGPL 3.0

Lemmy

Community · Social Media

14,555

Federated, self-hosted Reddit alternative with full community ownership and no corporate control.

View details
90
Repo Health
74
Technical
63
Dependency
Built with
Rust78%
PLpgSQL14%
Updated yesterday
Rust
100%
Other

Meilisearch

Search

59,012

Lightning-fast hybrid search engine with AI-powered semantic and full-text retrieval for modern applications.

View details
90
Repo Health
88
Technical
68
Dependency
Built with
Rust100%
Updated 5 days ago
Rust
84%
Apache 2.0

OpenShell

AI Agents · Developer Tools

8,270

The safe, private runtime that lets autonomous AI agents operate in sandboxed environments governed by declarative YAML policies — blocking data exfiltration, credential leaks, and unauthorized network activity before they happen.

View details
84
Repo Health
81
Technical
69
Dependency
Built with
Rust84%
Updated today
Go
80%
AGPL 3.0

PeerDB

Data Engineering · Databases

3,241

Postgres-native ETL that streams change data capture in real time to Snowflake, BigQuery, ClickHouse, S3, and Kafka — up to 10x faster than general-purpose pipelines, managed through a familiar Postgres SQL interface.

View details
88
Repo Health
76
Technical
68
Dependency
Built with
Go80%
TypeScript13%
Updated today
Python
55%
Other

PostHog

Analytics · Monitoring · Developer Tools

37,777

The all-in-one open source product platform combining analytics, session replay, feature flags, error tracking, AI observability, and a built-in data warehouse in a single self-hostable stack.

View details
92
Repo Health
80
Technical
67
Dependency
Built with
Python55%
TypeScript36%
Updated today
Rust
89%
Apache 2.0

Qdrant

Databases · AI Development · Search

34,058

Open-source vector database and search engine built in Rust for production-grade AI applications — from semantic search to RAG pipelines and recommendation systems.

View details
92
Repo Health
87
Technical
69
Dependency
Built with
Rust89%
Updated yesterday
Rust
98%

Stalwart

Collaboration

14,255

All-in-one secure mail and collaboration server covering IMAP, JMAP, SMTP, CalDAV, CardDAV, and WebDAV in a single memory-safe Rust binary.

View details
89
Repo Health
81
Technical
68
Dependency
Built with
Rust98%
Updated yesterday

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

Search