dart_jsonwebtoken
3.4.1, released 7 months ago by jonasroussel.com
A Dart library for creating, signing, decoding and verifying JSON Web Tokens (JWT).
What it does
It provides a simple API to generate JWTs with any supported algorithm, sign them with secret or key, decode tokens without verification, and verify signatures and claims. It also supports JWK conversion and defensive claim handling.
AI-written summary of version 3.4.1, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to issue or validate JWTs in a Dart/Flutter app
- You require support for multiple algorithms (HS, RS, ES, EdDSA)
- You want a pure Dart implementation without external native dependencies
Skip it when
- You only need to parse JWTs without verification
- You are building a minimal app that prefers a lighter dependency
Strengths
- All standard JWT algorithms supported
- Defensive type checks and timing-attack resistant HMAC
- JWK conversion helpers
- Pure Dart, works on all platforms
Weaknesses
- No built‑in token storage or refresh flow
- No integration with auth backends out of the box
- Requires manual key management
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 3
Add dependency to pubspec, import package, no build_runner needed
import 'package:dart_jsonwebtoken/dart_jsonwebtoken.dart';
final jwt = JWT({'id':123});
final token = jwt.sign(SecretKey('secret'));
final verified = JWT.verify(token, SecretKey('secret'));
print(verified.payload);Alternatives
Packages that do the same job and could replace dart_jsonwebtoken.
- built_value
not a JWT library, but can be used for value objects
88Compare - json_annotation
not a JWT library
84Compare
Works with
Packages commonly used together with dart_jsonwebtoken: ones it builds on, ones built on it, and its own family.
- clockdart_jsonwebtoken depends on itA fakeable wrapper for dart:core clock APIs.
- convertdart_jsonwebtoken depends on itEncoders and decoders for converting between different data representations.
- pointycastledart_jsonwebtoken depends on itA Dart library providing a wide range of cryptographic algorithms and primitives.
- gotrueBuilt on dart_jsonwebtokenDart client for Supabase Auth API
- livekit_clientBuilt on dart_jsonwebtokenFlutter Client SDK for LiveKit to build real-time video, audio, and data features.
- sign_in_with_apple_serverBuilt on dart_jsonwebtokenServer-side utilities for Sign in with Apple in Dart
- firebase_auth_mocksBuilt on dart_jsonwebtokenMocks for Firebase Auth to enable unit testing of authentication flows.
- firebase_admin_sdkBuilt on dart_jsonwebtokenFirebase Admin SDK implementation for Dart server environments