Python JWT libraries

Updated Nov 2026

Python JWT libraries create, sign, and verify JSON Web Tokens, the signed tokens that carry identity claims between services. Libraries that implement the full JOSE standards also encrypt tokens and manage the keys that sign them. These libraries let APIs and AI agents check who sent each request.

Popularity

PyJWT has the most monthly downloads in this comparison, at 761.0M.

LibraryMonthly downloadsStarsLast releaseLicense
PyJWT
761.0M
5.7KSep 2026MIT
Authlib
137.9M
5.5KNov 2026BSD-3-Clause
joserfc
128.5M
184Nov 2026BSD-3-Clause
python-jose
31.8M
1.8KMay 2025MIT
JWCrypto
19.4M
481Sep 2026LGPL-3.0-or-later
jwt
3.1M
157Jun 2025Apache-2.0
jwskate
1.7M
24Apr 2025MIT
Downloads: PyPI, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

Libraries and code examples

Encodes and decodes JSON Web Tokens.

Downloads / mo
761.0M
Stars
5.7K
Last release
2.15.1
License
MIT

Quickstart

From api.html
$ pip install "PyJWT[crypto]"
import os
import jwt
token = jwt.encode({'sub': '123'}, os.environ['JWT_SECRET'], algorithm='HS256')

PyJWT examples

From open-source projects on GitHub

Builds OAuth and OpenID Connect servers and clients.

Downloads / mo
137.9M
Stars
5.5K
Last release
1.9.9
License
BSD-3-Clause

Quickstart

From jwt.html
$ pip install Authlib
from authlib.jose import jwt
with open('private.pem', 'rb') as key_file:
    token = jwt.encode({'alg': 'RS256'}, {'sub': '123'}, key_file.read())

Authlib examples

From open-source projects on GitHub

Provides JOSE JWT encoding, decoding, and separate claim validation.

Downloads / mo
128.5M
Stars
184
Last release
1.8.0
License
BSD-3-Clause

Strengths

  • Supports signed and encrypted JWTs. Choose signed tokens or encrypted tokens through the JWT API.
  • Checks required and allowed claims. Use JWTClaimsRegistry to require claims and restrict accepted values.
  • Replaces deprecated Authlib JOSE. Use the separate JOSE library when migrating Authlib JWT code.

Limitations

  • Decoding skips claim validation. Validate token.claims separately with JWTClaimsRegistry.
  • Encryption needs its own registry. Pass JWERegistry when encoding or decoding encrypted JWTs.

Quickstart

From jwt.md
$ pip install joserfc
from joserfc import jwt
from joserfc.jwk import OctKey
key = OctKey.generate_key()
token = jwt.encode({'alg': 'HS256'}, {'sub': '123'}, key)

joserfc examples

From open-source projects on GitHub

Implements JOSE signing, encryption, and key handling in Python.

Downloads / mo
31.8M
Stars
1.8K
Last release
3.5.0
License
MIT

Strengths

  • Signs and encrypts JOSE messages. Use separate JWS and JWE APIs for signing and encryption.
  • Offers cryptographic backend choices. Choose the cryptography, pycryptodome, or native Python backend.

Limitations

  • Native backend cannot read certificates. Use the cryptography backend when keys arrive as certificates.

Quickstart

From README.rst
$ pip install "python-jose[cryptography]"
import os
from jose import jwt
token = jwt.encode({'sub': '123'}, os.environ['JWT_SECRET'], algorithm='HS256')

python-jose examples

From open-source projects on GitHub

Creates signed or encrypted JSON Web Token objects.

Downloads / mo
19.4M
Stars
481
Last release
1.6.1
License
LGPL-3.0-or-later

Strengths

  • Encrypts token payloads. Create encrypted JWTs with make_encrypted_token().
  • Accepts JSON Web Key sets. Pass a JWKSet when verification needs a set of candidate keys.

Limitations

  • Missing expiry is accepted. Set check_claims when expiration must be present.

Quickstart

From jwt.rst
$ pip install jwcrypto
from jwcrypto import jwk, jwt
key = jwk.JWK.generate(kty='oct', size=256)
token = jwt.JWT(header={'alg': 'HS256'}, claims={'sub': '123'})
token.make_signed_token(key)
serialized = token.serialize()

JWCrypto examples

From open-source projects on GitHub

Implements JSON Web Tokens.

Downloads / mo
3.1M
Stars
157
Last release
1.4.0
License
Apache-2.0

Quickstart

From README.md
$ pip install jwt
from jwt import JWT, jwk_from_pem
with open('private.pem', 'rb') as key_file:
    key = jwk_from_pem(key_file.read())
token = JWT().encode({'sub': '123'}, key, alg='RS256')

jwt examples

From open-source projects on GitHub
def create_access_token(data: dict, expires_delta: Optional[timedelta] = None) -> str:
    """Create a JWT access token with an expiration."""
    to_encode = data.copy()
    expire = datetime.now(timezone.utc) + (expires_delta or timedelta(minutes=ACCESS_TOKEN_EXPIRE_MINUTES))
    to_encode.update({"exp": get_int_from_datetime(expire)})
    signing_key = get_jwk_from_secret(SECRET_KEY)
    return instance.encode(to_encode, signing_key, alg='HS256')

Implements the JOSE standards, including JWS, JWK, JWE, and JWT.

Downloads / mo
1.7M
Stars
24
Last release
0.12.2
License
MIT

Quickstart

From README.md
$ pip install jwskate
from jwskate import Jwk, Jwt
key = Jwk.generate(alg='ES256')
token = Jwt.sign({'sub': '123'}, key)

FAQ

PyJWT suits applications that sign and verify tokens and fetch keys from a JWKS endpoint. joserfc and JWCrypto suit applications that also need encrypted tokens. Authlib suits applications that build OAuth or OpenID Connect clients and servers alongside their token handling.

PyJWT is a JSON Web Token implementation for Python that encodes and decodes signed tokens. Its PyJWKClient fetches signing keys from a JWKS endpoint.

python-jose is a JOSE implementation that signs, encrypts, and handles keys. It runs on the cryptography package, PyCryptodome, or a native Python backend.

joserfc implements the JOSE standards, including JWS, JWE, JWK, and JWT. It decodes a token and validates its claims as separate steps.

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