{
 "kind": "tool",
 "slug": "jsonwebtoken",
 "path": "tools/jsonwebtoken/",
 "name": "jsonwebtoken",
 "maker": null,
 "density": "profile",
 "crumbs": [
  [
   "Tools",
   "tools/"
  ],
  [
   "Auth and security libraries",
   "tools/auth-security/"
  ]
 ],
 "lead": "Create, verify and decode JSON Web Tokens for authentication and secure data transmission.",
 "chips": [
  {
   "label": "Auth and security libraries",
   "path": "tools/auth-security/"
  },
  {
   "label": "NPM"
  }
 ],
 "primary": {
  "label": "Copy install command",
  "copy": "npm install jsonwebtoken"
 },
 "links": [
  {
   "label": "GitHub",
   "href": "https://github.com/auth0/node-jsonwebtoken"
  },
  {
   "label": "Website",
   "href": "https://github.com/auth0/node-jsonwebtoken#readme"
  }
 ],
 "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": null,
   "note": "License from npm.",
   "src": "https://github.com/auth0/node-jsonwebtoken"
  },
  {
   "key": "maint",
   "label": "Maintained",
   "value": "Maintained",
   "status": "yes",
   "sub": "Last change Jun 25, 2026",
   "note": "",
   "src": "https://github.com/auth0/node-jsonwebtoken"
  },
  {
   "key": "pop",
   "label": "Used by agents' projects",
   "value": "149 projects",
   "status": "info",
   "sub": "#3 of 141 in its category",
   "note": "Dependency in 149 public GitHub projects set up for AI coding agents that we scanned (2.4%).",
   "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.",
 "blocks": [
  {
   "id": "overview",
   "nav": "Overview",
   "h2": "What jsonwebtoken does",
   "parts": [
    {
     "t": "prose",
     "text": "jsonwebtoken is the plain sign/verify/decode JWT library for Node.js, and since version 9 it refuses unsigned tokens, short RSA keys and mismatched key types unless you opt back in by name."
    }
   ]
  },
  {
   "id": "popularity",
   "nav": "Popularity",
   "h2": "jsonwebtoken popularity",
   "parts": [
    {
     "t": "stats",
     "items": [
      {
       "n": "79",
       "of": "/ 100",
       "l": "Gid Score, #122 overall"
      },
      {
       "n": "84.5M",
       "l": "downloads a week, npm"
      },
      {
       "n": "18.2K",
       "l": "GitHub stars"
      },
      {
       "n": "149",
       "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 jsonwebtoken is used",
   "parts": [
    {
     "t": "list",
     "items": [
      "jsonwebtoken is a dependency in 149 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (3.1% of the 4,867 JavaScript/TypeScript ones), #3 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 452; those are left out of every share on this page.",
      "The most used alternative in our scan is jose (108 projects).",
      "Projects that use it most often also use dotenv (70.5%), Express (60.4%), cors (53.7%).",
      "It is more common in projects set up for Devin Desktop (9.3%) than for OpenAI Codex (1.5%)."
     ]
    },
    {
     "t": "h3",
     "text": "By coding agent"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "84 projects, 3.4%",
       "v": "Cursor",
       "path": "agents/cursor/"
      },
      {
       "l": "78 projects, 2.4%",
       "v": "Claude Code",
       "path": "agents/claude-code/"
      },
      {
       "l": "61 projects, 2.0%",
       "v": "GitHub Copilot",
       "path": "agents/github-copilot/"
      },
      {
       "l": "26 projects, 9.3%",
       "v": "Devin Desktop",
       "path": "agents/devin-desktop/"
      },
      {
       "l": "10 projects, 7.1%",
       "v": "Kiro",
       "path": "agents/kiro/"
      },
      {
       "l": "8 projects, 1.7%",
       "v": "Gemini CLI",
       "path": "agents/gemini-cli/"
      },
      {
       "l": "7 projects, 1.5%",
       "v": "OpenAI Codex",
       "path": "agents/openai-codex/"
      },
      {
       "l": "7 projects, 6.3%",
       "v": "Roo Code",
       "path": "agents/roo-code/"
      }
     ]
    },
    {
     "t": "h3",
     "text": "Often used with"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "In 70.5% of its projects",
       "v": "dotenv",
       "path": "tools/dotenv/"
      },
      {
       "l": "In 60.4% of its projects",
       "v": "Express",
       "path": "tools/express/"
      },
      {
       "l": "In 53.7% of its projects",
       "v": "cors",
       "path": "tools/cors/"
      },
      {
       "l": "In 39.6% of its projects",
       "v": "bcryptjs",
       "path": "tools/bcryptjs/"
      },
      {
       "l": "In 59.7% of its projects",
       "v": "Zod",
       "path": "tools/zod/"
      },
      {
       "l": "In 35.6% of its projects",
       "v": "Helmet",
       "path": "tools/helmet/"
      },
      {
       "l": "In 34.2% of its projects",
       "v": "uuid",
       "path": "tools/uuid/"
      },
      {
       "l": "In 31.5% of its projects",
       "v": "Jest",
       "path": "tools/jest/"
      }
     ]
    }
   ]
  },
  {
   "id": "profile",
   "nav": "Profile",
   "h2": "jsonwebtoken in practice",
   "parts": [
    {
     "t": "h3",
     "text": "Strengths"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "Unsigned tokens and weak RSA keys are refused by default",
       "v": "In v9, <code>verify()</code> rejects unsigned tokens unless you list <code>none</code> in <code>options.algorithms</code>. Signing rejects RSA keys under 2048 bits unless you set <code>allowInsecureKeySizes</code>."
      },
      {
       "l": "Claim checks live in one verify call",
       "v": "<code>verify</code> takes expected values for audience, issuer, JWT ID, subject and nonce, plus <code>maxAge</code> and <code>clockTolerance</code>. The audience can be matched against strings or regular expressions."
      },
      {
       "l": "Errors you can branch on",
       "v": "Failures come back as <code>TokenExpiredError</code>, <code>NotBeforeError</code> or <code>JsonWebTokenError</code>. Each has a fixed message such as <code>'jwt expired'</code> or <code>'jwt malformed'</code>."
      },
      {
       "l": "Keys can be fetched per token",
       "v": "In callback mode, the key argument can be a function that looks up the key from the token header. The README shows this with <code>jwks-rsa</code> and the header's <code>kid</code>."
      }
     ]
    },
    {
     "t": "h3",
     "text": "Watch out for"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "decode() checks nothing",
       "v": "<code>jwt.decode</code> reads the payload without validating the signature. The README warns against using it for untrusted messages and points to <code>jwt.verify</code> instead."
      },
      {
       "l": "A verified payload is still user input",
       "v": "Even after verification, the README says a payload from an untrusted source must be sanitized, and you should only read the properties you expect."
      },
      {
       "l": "String durations without units mean milliseconds",
       "v": "<code>expiresIn</code>, <code>notBefore</code> and <code>maxAge</code> treat numbers as seconds. A unitless string is read as milliseconds, so <code>\"120\"</code> means <code>\"120ms\"</code>."
      }
     ]
    },
    {
     "t": "h3",
     "text": "Sign a token, then verify it (synchronous)"
    },
    {
     "t": "tabs",
     "label": "Example",
     "items": [
      {
       "tab": "Js",
       "code": "var jwt = require('jsonwebtoken');\nvar token = jwt.sign({ foo: 'bar' }, 'shhhhh');\n\n// verify a token symmetric - synchronous\nvar decoded = jwt.verify(token, 'shhhhh');\nconsole.log(decoded.foo) // bar\n\n// invalid token - synchronous\ntry {\n  var decoded = jwt.verify(token, 'wrong-secret');\n} catch(err) {\n  // err\n}"
      }
     ]
    }
   ]
  },
  {
   "id": "more",
   "nav": null,
   "spy_as": "profile",
   "h2": "More about jsonwebtoken",
   "parts": [
    {
     "t": "more",
     "items": [
      {
       "title": "Head to head",
       "items": [
        {
         "text": "jsonwebtoken vs jose",
         "note": "used together in 7 projects",
         "path": "tools/compare/jsonwebtoken-vs-jose/"
        }
       ]
      },
      {
       "title": "Packages around it",
       "items": [
        "dotenv: env variables",
        "express: web framework",
        "cors: CORS middleware",
        "bcryptjs: password hashing",
        "zod: schema validation",
        "axios: HTTP client"
       ]
      },
      {
       "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": "cryptography",
         "path": "tools/cryptography/"
        },
        {
         "text": "PyJWT",
         "path": "tools/pyjwt/"
        },
        {
         "text": "Better Auth",
         "path": "tools/better-auth/"
        },
        {
         "text": "DOMPurify",
         "path": "tools/dompurify/"
        },
        {
         "text": "Helmet",
         "path": "tools/helmet/"
        },
        {
         "text": "bcrypt (JavaScript)",
         "path": "tools/bcrypt-npm/"
        }
       ]
      }
     ]
    }
   ]
  },
  {
   "id": "alternatives",
   "nav": "Alternatives",
   "h2": "Alternatives",
   "parts": [
    {
     "t": "alts",
     "items": [
      {
       "name": "jsonwebtoken",
       "me": true,
       "facts": [
        "MIT",
        "Gid 79",
        "84.5M/wk"
       ]
      },
      {
       "name": "jose",
       "why": "Comprehensive JWT and JWK handling for Node.js and web runtimes.",
       "path": "tools/jose/",
       "facts": [
        "MIT",
        "Gid 75",
        "244M/wk"
       ]
      },
      {
       "name": "Passport.js",
       "why": "Modular authentication middleware for Node.js supporting OAuth, JWT and local strategies.",
       "path": "tools/passport/",
       "facts": [
        "MIT",
        "Gid 69",
        "10.5M/wk"
       ]
      }
     ],
     "more": "Compare jsonwebtoken with another tool",
     "more_path": "tools/compare/"
    }
   ]
  },
  {
   "id": "start",
   "nav": "Get started",
   "h2": "Get started",
   "parts": [
    {
     "t": "install",
     "intro": "Install it.",
     "code": "npm install jsonwebtoken"
    },
    {
     "t": "h3",
     "text": "Rules for your agent"
    },
    {
     "t": "rules",
     "label": "Paste into AGENTS.md or CLAUDE.md",
     "text": "## jsonwebtoken\n- Use `jwt.verify` for any token from a client or external request. Never use `jwt.decode`, which does not check the signature.\n- Pass `algorithms` explicitly to `verify` (for example `['RS256']`). Do not add `'none'` unless unsigned tokens are really intended.\n- Treat the decoded payload as user input. Read only the properties you expect.\n- Give `expiresIn`, `notBefore` and `maxAge` a number of seconds or a string with units (`'1h'`, `'7d'`). A unitless string like `'120'` means milliseconds.\n- Put a claim either in the payload (`exp`, `nbf`, `aud`, `sub`, `iss`) or in the options, never both. Use an object literal payload so claims get set.\n- Use RSA keys of at least 2048 bits, and never sign HS* tokens with an asymmetric key. Do not set `allowInsecureKeySizes` or `allowInvalidAsymmetricKeyTypes` in new code.\n- Handle `TokenExpiredError`, `NotBeforeError` and `JsonWebTokenError` separately when mapping failures to responses.\n"
    }
   ]
  }
 ],
 "glance": [
  [
   "Package",
   "npm jsonwebtoken"
  ],
  [
   "Category",
   "Auth and security libraries"
  ],
  [
   "License",
   "MIT"
  ],
  [
   "Latest version",
   "9.0.3, December 4, 2025"
  ],
  [
   "On GitHub since",
   "July 2013"
  ],
  [
   "Gid Score",
   "78.7"
  ],
  [
   "Rank in category",
   "#3 of 141"
  ],
  [
   "GitHub",
   "auth0/node-jsonwebtoken"
  ],
  [
   "Last change",
   "Jun 25, 2026"
  ]
 ],
 "good": [],
 "checked_line": "From the package registry, GitHub and our scan of public agent projects; numbers update daily.",
 "logo": "https://agentgid.com/media/avatars/auth0.png"
}