Library / SDK
jpadilla/pyjwt avatar
jpadilla/pyjwt

PyJWT: the small JWT library where the security work shows up

JSON Web Token implementation in Python

5,728 stars842 forksPythonMIT

At a glance

What is it?
A pure Python implementation of RFC 7519 with a four-line API, one optional crypto extra and a SECURITY.md kept in the repository.
Who is it for?
Reading PyJWT's changelog is a better lesson in JWT than most tutorials. The API is four calls, the install is one line, and the hard part is not signing tokens but deciding which algorithms you will accept and refusing everything else.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 4 days ago.
What is it written in?
Mainly Python, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on November 22, 2026, and from our analysis. They are not legal advice.

From daily snapshots

Star history

  • jpadilla/pyjwt5,728 ★ · +15
Star history
Repository2026-10-072026-11-22
jpadilla/pyjwt5.7k5.7k

15 Stars in the last 46 days, measured from the daily GitHub snapshot. Compare with other projects

Editorial analysis

Four calls and one optional dependency

The entire public surface a normal application touches is four lines long, and they are the four lines in the README's usage block:

python
>>> import jwt
>>> encoded = jwt.encode({"some": "payload"}, "secret", algorithm="HS256")
>>> print(encoded)
>>> jwt.decode(encoded, "secret", algorithms=["HS256"])
{'some': 'payload'}

`jwt.encode` takes a payload, a key and an explicit algorithm. `jwt.decode` takes the token, the key and an explicit list of allowed algorithms. Both the algorithm and the allow-list are passed explicitly as keyword arguments in the README's example, which puts the two decisions that JWT implementations most often get wrong in plain view.

The install is `pip install PyJWT`, and the manifest carries one unconditional dependency: typing_extensions at 4.0 or newer, but only for Python below 3.11. The package requires Python 3.9 or newer and declares support through 3.15. The interesting part is the extras group, which is a single entry called crypto requiring cryptography 3.4.0 or newer. That is the boundary: HMAC signing and verification are pure Python and always work, while RSA and ECDSA verification need the optional package. A deployment that accepts RS256 tokens without installing the extra fails at verify time rather than at install time, which is a distinction worth knowing before you debug it.

The repository credits the original implementation to progrium and the current maintainer to Jose Padilla. It is classified as Production/Stable on PyPI, has 5,722 stars and 826 forks, and the last push was 2026-10-26.

Version 2.13.0 is a security release and the details matter

Recent GitHub releases are 2.15.1, published 2026-09-28, 2.15.0, published 2026-09-23, and 2.14.0, published 2026-09-11. Release history is kept in CHANGELOG.rst at the repository root, with SECURITY.md beside it.

Why the algorithm argument is mandatory rather than optional

Almost every JWT vulnerability you will read about traces back to a verifier that accepts whatever algorithm the token claims. The classic attack takes a server that expects RS256, has the RSA public key on hand, and is handed a token whose header says HS256. The server signs the token with HMAC using the public key as the secret, and the signature verifies. The attacker did not need the private key at all.

PyJWT closes this off at the API level. The README's example passes `algorithm="HS256"` to `jwt.encode` and an explicit `algorithms=["HS256"]` list to `jwt.decode`.

That is a design choice rather than an accident, and it explains why the allow-list appears in the README's four-line example at all.

Release history is kept in CHANGELOG.rst at the repository root.

A tidy tree with the security policy kept in the open

The repository layout is small enough to read in a minute. The `jwt/` directory is the package itself, `tests/` holds the test suite, `docs/` builds to pyjwt.readthedocs.io, and there is a `CHANGELOG.rst` at the root next to `AUTHORS.rst`, `CODE_OF_CONDUCT.md`, `LICENSE` and `SECURITY.md`. A separate `tox.ini` drives the multi-environment test run the README points at with a single `tox` invocation, and `.pre-commit-config.yaml` handles formatting.

The build configuration moved to `pyproject.toml` with setuptools as the backend at 77.0.3 or newer, and the package uses PEP 621 metadata throughout: authors, classifiers, dependencies and keywords are all declared there rather than in a setup.py. The dev dependency group pins coverage at 7.10.7 and pytest at 8.4.2 or newer but below 9.0.0, with cryptography at 3.4.0 or newer for the crypto tests, plus sphinx and the sphinx-rtd-theme for docs. Smaller groups named docs and tests let contributors install a slice rather than the whole thing.

The dependency groups are defined under a dependency-groups key rather than optional-dependencies, with the one exception of crypto, which is a real extra because end users need it. That distinction is the packaging story in miniature: contributors get a full environment, users get one optional extra, and the runtime dependency list stays at a single conditional entry.

Coverage is configured with source paths that include site-packages and the jwt directory, which is the standard trick for measuring a package after installation, and the report excludes `if TYPE_CHECKING` blocks so type-only lines do not distort the numbers.

Editorial conclusion

Reading PyJWT's changelog is a better lesson in JWT than most tutorials. The API is four calls, the install is one line, and the hard part is not signing tokens but deciding which algorithms you will accept and refusing everything else. The optional crypto extra is the other thing to understand, because RSA and ECDSA verification silently need the cryptography package and HMAC does not. Start with pip install PyJWT, pass an explicit algorithms list on every decode call, and read SECURITY.md before you rely on a JWKS endpoint you do not control.

Frequently asked questions

How do I install PyJWT?

Install it with pip: `pip install PyJWT`. That is the whole requirement for HMAC tokens such as HS256. If you plan to verify RSA or ECDSA tokens you also need the crypto extra, which pulls in the cryptography package at 3.4.0 or newer.

Is it possible to decode a PyJWT without the secret key?

You can read the payload without the key, because JWT payloads are base64url encoded rather than encrypted. What you cannot do is verify the signature without the right key, and that verification is the only thing that makes a token trustworthy. Any code that trusts claims from an unverified decode is trusting whoever signed the token.

What are JWTs used for?

They carry signed claims between parties without a shared session store, which is why they show up in authentication and in service-to-service calls. The signature proves the claims were issued by the holder of a key you already trust, and the claim set usually carries an issuer, an audience and an expiry that the verifying side checks.

What is the difference between JWT and PyJWT?

JWT is the specification, RFC 7519, which defines the token format and the algorithms. PyJWT is one Python library that implements it, and it is not the only one. The practical difference between libraries is less about format support and much more about how strictly they handle the algorithm argument and key material.

Official sources

  1. jpadilla/pyjwt on GitHub
  2. License: MIT
  3. Project website
  4. README
  5. Releases
Community

Where developers are discussing it

Posts on Hacker News, dev.to and Lobsters that link to this repository, found by our scan of those communities. 1 in the last 30 days; newest first.

Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/jpadilla-pyjwt.svg)](https://hysenlabs.com/projects/jpadilla-pyjwt)

Star history chart for your README

markdown
[![Star history](https://hysenlabs.com/chart/jpadilla-pyjwt.svg)](https://hysenlabs.com/projects/jpadilla-pyjwt)

Was this useful?