Skip to content
pubscout

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).

WASM-ready
$ flutter pub add dart_jsonwebtoken
Source repository

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.

Works with

Packages commonly used together with dart_jsonwebtoken: ones it builds on, ones built on it, and its own family.