{
 "kind": "tool",
 "slug": "pyjwt",
 "path": "tools/pyjwt/",
 "name": "PyJWT",
 "maker": null,
 "density": "full",
 "crumbs": [
  [
   "Tools",
   "tools/"
  ],
  [
   "Auth and security libraries",
   "tools/auth-security/"
  ]
 ],
 "lead": "Make and check login tokens in Python.",
 "chips": [
  {
   "label": "Auth and security libraries",
   "path": "tools/auth-security/"
  },
  {
   "label": "PYPI"
  }
 ],
 "primary": {
  "label": "Copy install command",
  "copy": "pip install pyjwt"
 },
 "links": [
  {
   "label": "GitHub",
   "href": "https://github.com/jpadilla/pyjwt"
  },
  {
   "label": "Website",
   "href": "https://github.com/jpadilla/pyjwt"
  }
 ],
 "track": "New versions, deprecation and license changes on your dashboard",
 "verdicts": [
  {
   "key": "license",
   "label": "License",
   "value": "MIT",
   "status": "yes",
   "sub": "Use it in paid apps",
   "quote": "to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software",
   "note": "MIT allows use in paid and closed products.",
   "src": "https://github.com/jpadilla/pyjwt/blob/master/LICENSE"
  },
  {
   "key": "maint",
   "label": "Maintained",
   "value": "Maintained",
   "status": "yes",
   "sub": "Last change Nov 23, 2026",
   "note": "Latest GitHub release Sep 28, 2026. ",
   "src": "https://github.com/jpadilla/pyjwt"
  },
  {
   "key": "pop",
   "label": "Used by agents' projects",
   "value": "118 projects",
   "status": "info",
   "sub": "#5 of 141 in its category",
   "note": "Dependency in 118 public GitHub projects set up for AI coding agents that we scanned (1.9%).",
   "src": null
  },
  {
   "key": "agent",
   "label": "Agent access",
   "value": "Install only",
   "status": "info",
   "sub": null,
   "note": "Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.",
   "src": null
  }
 ],
 "vfoot": "From the package registry and GitHub, checked daily; card checked Nov 11, 2026.",
 "blocks": [
  {
   "id": "overview",
   "nav": "Overview",
   "h2": "What PyJWT does",
   "parts": [
    {
     "t": "prose",
     "text": "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."
    },
    {
     "t": "h3",
     "text": "What people build with it"
    },
    {
     "t": "uses",
     "items": [
      {
       "title": "Keep users logged in to your service",
       "text": "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.",
       "idea": false
      },
      {
       "title": "Accept tokens from a sign-in provider",
       "text": "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.",
       "idea": false
      },
      {
       "title": "Let one service vouch for another",
       "text": "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.",
       "idea": false
      },
      {
       "title": "Links that expire, like password reset",
       "text": "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.",
       "idea": true
      },
      {
       "title": "Look inside a token while debugging",
       "text": "Your assistant reads which key and algorithm a token says it uses, before choosing how to check it, without trusting its contents yet.",
       "idea": false
      }
     ]
    }
   ]
  },
  {
   "id": "popularity",
   "nav": "Popularity",
   "h2": "PyJWT popularity",
   "parts": [
    {
     "t": "stats",
     "items": [
      {
       "n": "74",
       "of": "/ 100",
       "l": "Gid Score, #220 overall"
      },
      {
       "n": "176M",
       "l": "downloads a week, pypi"
      },
      {
       "n": "5,729",
       "l": "GitHub stars"
      },
      {
       "n": "118",
       "l": "agent projects use it"
      }
     ]
    },
    {
     "t": "small",
     "text": "Gid Score measures public popularity and activity, not quality.",
     "link": "How the Gid Score is calculated",
     "path": "tools/top/"
    }
   ]
  },
  {
   "id": "usage",
   "nav": "How it is used",
   "h2": "How PyJWT is used",
   "parts": [
    {
     "t": "list",
     "items": [
      "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%)."
     ]
    },
    {
     "t": "h3",
     "text": "By coding agent"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "67 projects, 2.0%",
       "v": "Claude Code",
       "path": "agents/claude-code/"
      },
      {
       "l": "64 projects, 2.1%",
       "v": "GitHub Copilot",
       "path": "agents/github-copilot/"
      },
      {
       "l": "50 projects, 2.0%",
       "v": "Cursor",
       "path": "agents/cursor/"
      },
      {
       "l": "6 projects, 1.8%",
       "v": "OpenClaw",
       "path": "agents/openclaw/"
      },
      {
       "l": "6 projects, 1.3%",
       "v": "OpenAI Codex",
       "path": "agents/openai-codex/"
      }
     ]
    },
    {
     "t": "h3",
     "text": "Often used with"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "In 72.9% of its projects",
       "v": "Pydantic",
       "path": "tools/pydantic/"
      },
      {
       "l": "In 70.3% of its projects",
       "v": "python-dotenv",
       "path": "tools/python-dotenv/"
      },
      {
       "l": "In 70.3% of its projects",
       "v": "Uvicorn",
       "path": "tools/uvicorn/"
      },
      {
       "l": "In 66.1% of its projects",
       "v": "FastAPI",
       "path": "tools/fastapi/"
      },
      {
       "l": "In 61.0% of its projects",
       "v": "Requests",
       "path": "tools/requests-py/"
      },
      {
       "l": "In 57.6% of its projects",
       "v": "python-multipart",
       "path": "tools/python-multipart/"
      },
      {
       "l": "In 52.5% of its projects",
       "v": "cryptography",
       "path": "tools/cryptography/"
      },
      {
       "l": "In 51.7% of its projects",
       "v": "PyYAML",
       "path": "tools/pyyaml/"
      }
     ]
    }
   ]
  },
  {
   "id": "profile",
   "nav": "Profile",
   "h2": "PyJWT in practice",
   "parts": [
    {
     "t": "h3",
     "text": "Strengths"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "Two calls cover the basic round trip",
       "v": "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."
      },
      {
       "l": "Symmetric and public-key algorithms in one place",
       "v": "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."
      },
      {
       "l": "JWKS and OIDC are documented, not left to you",
       "v": "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>."
      },
      {
       "l": "Claim and key checks have their own sections",
       "v": "The docs cover registered claim names, key length validation and requiring that specific claims be present."
      }
     ]
    },
    {
     "t": "h3",
     "text": "Watch out for"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "Package name and import name differ",
       "v": "You install <code>PyJWT</code> but import <code>jwt</code>. Code and requirements files should use each name in its own place."
      },
      {
       "l": "Crypto dependencies are a separate, optional step",
       "v": "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."
      },
      {
       "l": "Unvalidated reads exist",
       "v": "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."
      }
     ]
    },
    {
     "t": "h3",
     "text": "Encode and decode an HS256 token"
    },
    {
     "t": "tabs",
     "label": "Example",
     "items": [
      {
       "tab": "Pycon",
       "code": ">>> import jwt\n>>> encoded = jwt.encode({\"some\": \"payload\"}, \"secret\", algorithm=\"HS256\")\n>>> print(encoded)\neyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzb21lIjoicGF5bG9hZCJ9.4twFt5NiznN84AWoo1d7KO1T_yoc0Z6XOpOVswacPZg\n>>> jwt.decode(encoded, \"secret\", algorithms=[\"HS256\"])\n{'some': 'payload'}"
      }
     ]
    }
   ]
  },
  {
   "id": "more",
   "nav": null,
   "spy_as": "profile",
   "h2": "More about PyJWT",
   "parts": [
    {
     "t": "more",
     "items": [
      {
       "title": "Funding",
       "path": "tools/funding/",
       "items": [
        "GitHub Sponsors: https://github.com/jpadilla",
        "3 GitHub sponsors"
       ]
      },
      {
       "title": "Head to head",
       "items": [
        {
         "text": "PyJWT vs python-jose",
         "note": "used together in 7 projects",
         "path": "tools/compare/pyjwt-vs-python-jose/"
        }
       ]
      },
      {
       "title": "Packages around it",
       "items": [
        "pydantic: Data validation",
        "python-dotenv: .env config loading",
        "uvicorn: ASGI server",
        "fastapi: Web API framework",
        "requests: HTTP client",
        "python-multipart: Form data parsing"
       ]
      },
      {
       "title": "More in Auth and security libraries",
       "path": "tools/auth-security/",
       "items": [
        {
         "text": "bcryptjs",
         "path": "tools/bcryptjs/"
        },
        {
         "text": "NextAuth.js",
         "path": "tools/next-auth/"
        },
        {
         "text": "jsonwebtoken",
         "path": "tools/jsonwebtoken/"
        },
        {
         "text": "cryptography",
         "path": "tools/cryptography/"
        },
        {
         "text": "jose",
         "path": "tools/jose/"
        },
        {
         "text": "Better Auth",
         "path": "tools/better-auth/"
        },
        {
         "text": "DOMPurify",
         "path": "tools/dompurify/"
        },
        {
         "text": "Helmet",
         "path": "tools/helmet/"
        }
       ]
      }
     ]
    }
   ]
  },
  {
   "id": "alternatives",
   "nav": "Alternatives",
   "h2": "Alternatives",
   "parts": [
    {
     "t": "alts",
     "items": [
      {
       "name": "PyJWT",
       "me": true,
       "facts": [
        "MIT",
        "Gid 74",
        "176M/wk"
       ]
      },
      {
       "name": "Authlib",
       "why": "Pick Authlib when you need a whole OAuth or OpenID Connect sign-in flow, client or server, not only token checks.",
       "path": "tools/authlib/",
       "facts": [
        "BSD",
        "Gid 70",
        "38.2M/wk"
       ]
      },
      {
       "name": "JWCrypto",
       "why": "Pick jwcrypto when you also need encrypted tokens (JWE), not only signed ones.",
       "path": "tools/jwcrypto/",
       "facts": []
      },
      {
       "name": "itsdangerous",
       "why": "Pick itsdangerous for signed cookies or one-time links inside one Python app, where the JWT standard is not needed.",
       "path": "tools/itsdangerous/",
       "facts": []
      },
      {
       "name": "jsonwebtoken",
       "why": "Pick jsonwebtoken when the server that makes or checks tokens runs on Node.js instead of Python.",
       "path": "tools/jsonwebtoken/",
       "facts": []
      },
      {
       "name": "python-jose",
       "why": "JOSE (JSON Object Signing and Encryption) implementation for Python.",
       "path": "tools/python-jose/",
       "facts": [
        "MIT",
        "Gid 58",
        "7.1M/wk"
       ]
      }
     ],
     "more": "Compare PyJWT with another tool",
     "more_path": "tools/compare/"
    }
   ]
  },
  {
   "id": "start",
   "nav": "Get started",
   "h2": "Get started",
   "parts": [
    {
     "t": "prompt",
     "text": "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."
    },
    {
     "t": "steps",
     "items": [
      {
       "text": "Install PyJWT into your project's Python environment; add the crypto extra if you will use RSA or elliptic-curve keys.",
       "code": "$ pip install pyjwt\n$ pip install pyjwt[crypto]\n",
       "src": "https://pyjwt.readthedocs.io/en/stable/installation.html"
      },
      {
       "text": "Make a token and read it back. The import name is jwt.",
       "code": ">>> import jwt\n>>> encoded_jwt = jwt.encode({\"some\": \"payload\"}, \"secret\", algorithm=\"HS256\")\n>>> jwt.decode(encoded_jwt, \"secret\", algorithms=[\"HS256\"])\n{'some': 'payload'}\n",
       "src": "https://pyjwt.readthedocs.io/en/stable/"
      }
     ]
    },
    {
     "t": "h3",
     "text": "Rules for your agent"
    },
    {
     "t": "rules",
     "label": "Paste into AGENTS.md or CLAUDE.md",
     "text": "## PyJWT\n- Add `PyJWT` (or `pyjwt`) to requirements, but write `import jwt` in code.\n- Encode with a single `algorithm=\"...\"`. Decode with an explicit list, `algorithms=[\"...\"]`, as the README does.\n- Use only the verifying `jwt.decode` for auth decisions. The docs' \"Reading the Claimset without Validation\" path is not a verification step.\n- For RS256, PS256, EdDSA or ES256, read the docs' \"Cryptographic Dependencies (Optional)\" section before installing.\n- 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.\n- Check keys against the docs' \"Minimum Key Length Requirements\". Use the \"Requiring Presence of Claims\" section when a claim must exist.\n"
    },
    {
     "t": "h3",
     "text": "Mistakes to avoid"
    },
    {
     "t": "mistakes",
     "items": [
      {
       "dont": "jwt.decode(token, key) with no algorithms argument",
       "fix": "jwt.decode(token, key, algorithms=[\"HS256\"]) with the exact algorithms you issue",
       "why": "Since 2.0 the algorithms list is required; in our run the call without it raised DecodeError."
      },
      {
       "dont": "jwt.encode(...).decode(\"utf-8\") from 1.x tutorials",
       "fix": "Use the return value of jwt.encode as it is; it is already a str",
       "why": "Since 2.0 tokens come back as text; in our run .decode raised AttributeError 'str' object has no attribute 'decode'."
      },
      {
       "dont": "jwt.decode(token, verify=False) to peek at a token",
       "fix": "jwt.decode(token, options={\"verify_signature\": False}) for debugging only, or jwt.get_unverified_header(token)",
       "why": "The old verify parameter was dropped in 2.0, and claims read without checking cannot be trusted."
      },
      {
       "dont": "pip install pyjwt and then algorithm=\"RS256\"",
       "fix": "pip install \"pyjwt[crypto]\" (keep it this way in requirements files)",
       "why": "RSA, ECDSA and EdDSA need the cryptography package, which the plain install does not bring."
      },
      {
       "dont": "A short HS256 secret such as \"secret\" or a 6-letter word",
       "fix": "secrets.token_hex(32) or longer, kept in server settings; consider options enforce_minimum_key_length True",
       "why": "Keys shorter than the hash output draw InsecureKeyLengthWarning (our run showed it for \"secret\")."
      }
     ]
    }
   ]
  },
  {
   "id": "faq",
   "nav": "Questions",
   "h2": "Questions",
   "parts": [
    {
     "t": "faq",
     "items": [
      {
       "q": "Why does jwt.decode fail with \"It is required that you pass in a value for the algorithms argument\"?",
       "a": "Since version 2.0 you must list the algorithms you accept, for example algorithms=[\"HS256\"]; this blocks tokens that switch to a weaker algorithm.",
       "evidence": {
        "url": "https://pyjwt.readthedocs.io/en/stable/changelog.html",
        "quote": "Require explicit algorithms in jwt.decode(...) by default"
       }
      },
      {
       "q": "Does it check expiry by itself?",
       "a": "Yes, when the token has an exp claim; an expired token raises ExpiredSignatureError. To require exp in every token, list it in options require.",
       "evidence": {
        "url": "https://pyjwt.readthedocs.io/en/stable/usage.html",
        "quote": "If you wish to require one or more claims to be present in the claimset, you can set the require parameter to include these claims."
       }
      },
      {
       "q": "Can I allow a few seconds of clock difference between servers?",
       "a": "Yes, pass leeway in seconds (or as a timedelta) to jwt.decode.",
       "evidence": {
        "url": "https://pyjwt.readthedocs.io/en/stable/usage.html",
        "quote": "Instead of specifying the leeway as a number of seconds, a datetime.timedelta instance can be used."
       }
      },
      {
       "q": "Can I use it in a paid product?",
       "a": "Yes, it is under the MIT license; keep its notice with copies of the code.",
       "evidence": {
        "url": "https://github.com/jpadilla/pyjwt/blob/master/LICENSE",
        "quote": "The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software."
       }
      }
     ]
    }
   ]
  }
 ],
 "glance": [
  [
   "Package",
   "pypi pyjwt"
  ],
  [
   "Category",
   "Auth and security libraries"
  ],
  [
   "License",
   "MIT"
  ],
  [
   "Latest version",
   "2.15.1, September 28, 2026"
  ],
  [
   "On GitHub since",
   "February 2011"
  ],
  [
   "Gid Score",
   "74.4"
  ],
  [
   "Rank in category",
   "#5 of 141"
  ],
  [
   "GitHub",
   "jpadilla/pyjwt"
  ],
  [
   "Last change",
   "Nov 23, 2026"
  ]
 ],
 "good": [
  "Anyone holding a token can read what is inside it; the signature only stops changes. Do not put secrets such as passwords into a token.",
  "RSA, ECDSA and EdDSA keys need the extra cryptography package; the plain install covers only shared-secret signing.",
  "Short secret keys draw a warning by default, and you can make them an error. A shared secret for HS256 should be at least 32 bytes."
 ],
 "checked_line": "Read by AgentGid from 11 official pages, card checked Nov 11, 2026; numbers update daily.",
 "logo": "https://agentgid.com/media/avatars/jpadilla.png"
}