1. License
“to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software”
MIT allows use in paid and closed products.
github.com/jpadilla/pyjwt/blob/master/LICENSE3. Used by agents' projects
Dependency in 118 public GitHub projects set up for AI coding agents that we scanned (1.9%).
4. Agent access
Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.
From the package registry and GitHub, checked daily; card checked Nov 11, 2026. Tap a verdict to see its source.How we checkedReport an error
What PyJWT does
PyJWT is a free Python library for JSON Web Tokens, the signed text passes many apps use to keep a person logged in. Your server makes a token after login, and later checks that nobody changed it and that it has not expired. It does not store passwords and does not handle the login screen itself.
What people build with it
Keep users logged in to your service
After a person signs in, your Python backend hands out a token that says who they are and ends in 15 minutes; every later request is checked with it.
Accept tokens from a sign-in provider
Your app lets people log in through an outside identity service and checks its tokens with the public keys that service publishes, so you never hold its secret.
Let one service vouch for another
Your main app signs a token with a private key; the billing service checks it with the matching public key and refuses tokens meant for someone else.
Links that expire, like password reset Idea
A reset or invite link carries a short-lived token with the user's ID, so it stops working after an hour without a database lookup.
Look inside a token while debugging
Your assistant reads which key and algorithm a token says it uses, before choosing how to check it, without trusting its contents yet.
PyJWT popularity
Gid Score measures public popularity and activity, not quality. How the Gid Score is calculated
How PyJWT is used
- PyJWT is a dependency in 118 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (7.3% of the 1,623 Python ones), #5 of 141 in auth and security libraries.
- Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 899; those are left out of every share on this page.
- The most used alternative in our scan is python-jose (58 projects).
- Projects that use it most often also use Pydantic (72.9%), python-dotenv (70.3%), Uvicorn (70.3%).
By coding agent
Often used with
PyJWT in practice
Strengths
The README's usage section is one <code>jwt.encode</code> call with a payload, a secret and <code>algorithm="HS256"</code>, and one <code>jwt.decode</code> call that returns the original dict. There is no client object or setup step in the basic case.
The docs have worked encode/decode examples for HS256, RS256 and PS256 (RSA), EdDSA (Ed25519) and ES256 (ECDSA). Separate pages cover digital signature algorithms and minimum key lengths.
The usage docs include retrieving RSA signing keys from a JWKS endpoint and an OIDC login flow. The API reference lists <code>PyJWK</code>, <code>PyJWKSet</code> and <code>PyJWKClient</code>.
The docs cover registered claim names, key length validation and requiring that specific claims be present.
Watch out for
You install <code>PyJWT</code> but import <code>jwt</code>. Code and requirements files should use each name in its own place.
The docs list "Cryptographic Dependencies (Optional)" as its own installation section. Read it before assuming a plain <code>pip install pyjwt</code> covers every algorithm in the examples.
The docs document reading the claimset and the headers without validation. Those reads are not the same as a verified <code>decode</code>, so do not use them to grant access.
Encode and decode an HS256 token
>>> import jwt
>>> encoded = jwt.encode({"some": "payload"}, "secret", algorithm="HS256")
>>> print(encoded)
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzb21lIjoicGF5bG9hZCJ9.4twFt5NiznN84AWoo1d7KO1T_yoc0Z6XOpOVswacPZg
>>> jwt.decode(encoded, "secret", algorithms=["HS256"])
{'some': 'payload'}More about PyJWT
Funding
- GitHub Sponsors: https://github.com/jpadilla
- 3 GitHub sponsors
Head to head
- PyJWT vs python-jose used together in 7 projects
Packages around it
- pydantic: Data validation
- python-dotenv: .env config loading
- uvicorn: ASGI server
- fastapi: Web API framework
- requests: HTTP client
- python-multipart: Form data parsing
More in Auth and security libraries
Alternatives
PyJWT This page
Pick Authlib when you need a whole OAuth or OpenID Connect sign-in flow, client or server, not only token checks.
Pick jwcrypto when you also need encrypted tokens (JWE), not only signed ones.
Pick itsdangerous for signed cookies or one-time links inside one Python app, where the JWT standard is not needed.
Pick jsonwebtoken when the server that makes or checks tokens runs on Node.js instead of Python.
JOSE (JSON Object Signing and Encryption) implementation for Python.
Get started
Tell your AI assistant
“Use PyJWT (pin pyjwt[crypto]==2.15.1) to issue a 15-minute HS256 login token with sub and exp after sign-in, read the secret from the SECRET_KEY setting, and on each request call jwt.decode with algorithms=["HS256"] and options require ["exp", "sub"], answering 401 on any jwt.PyJWTError.”
Install PyJWT into your project's Python environment; add the crypto extra if you will use RSA or elliptic-curve keys.
$ pip install pyjwt $ pip install pyjwt[crypto]Make a token and read it back. The import name is jwt.
>>> import jwt >>> encoded_jwt = jwt.encode({"some": "payload"}, "secret", algorithm="HS256") >>> jwt.decode(encoded_jwt, "secret", algorithms=["HS256"]) {'some': 'payload'}
Rules for your agent
## PyJWT
- Add `PyJWT` (or `pyjwt`) to requirements, but write `import jwt` in code.
- Encode with a single `algorithm="..."`. Decode with an explicit list, `algorithms=["..."]`, as the README does.
- Use only the verifying `jwt.decode` for auth decisions. The docs' "Reading the Claimset without Validation" path is not a verification step.
- For RS256, PS256, EdDSA or ES256, read the docs' "Cryptographic Dependencies (Optional)" section before installing.
- When signing keys come from an identity provider, follow the docs' "Retrieve RSA signing keys from a JWKS endpoint" section and `PyJWKClient` instead of hand-rolling key fetching.
- Check keys against the docs' "Minimum Key Length Requirements". Use the "Requiring Presence of Claims" section when a claim must exist.
Mistakes to avoid
Since 2.0 the algorithms list is required; in our run the call without it raised DecodeError.
Since 2.0 tokens come back as text; in our run .decode raised AttributeError 'str' object has no attribute 'decode'.
The old verify parameter was dropped in 2.0, and claims read without checking cannot be trusted.
RSA, ECDSA and EdDSA need the cryptography package, which the plain install does not bring.
Keys shorter than the hash output draw InsecureKeyLengthWarning (our run showed it for "secret").
Questions
Why does jwt.decode fail with "It is required that you pass in a value for the algorithms argument"?
Since version 2.0 you must list the algorithms you accept, for example algorithms=["HS256"]; this blocks tokens that switch to a weaker algorithm.
Does it check expiry by itself?
Yes, when the token has an exp claim; an expired token raises ExpiredSignatureError. To require exp in every token, list it in options require.
Can I allow a few seconds of clock difference between servers?
Yes, pass leeway in seconds (or as a timedelta) to jwt.decode.
Can I use it in a paid product?
Yes, it is under the MIT license; keep its notice with copies of the code.