{
 "kind": "tool",
 "slug": "jinja2",
 "path": "tools/jinja2/",
 "name": "Jinja2",
 "maker": null,
 "density": "profile",
 "crumbs": [
  [
   "Tools",
   "tools/"
  ],
  [
   "Markdown, editors and content",
   "tools/content-editors/"
  ]
 ],
 "lead": "Fast and expressive template engine for Python with powerful flexibility.",
 "chips": [
  {
   "label": "Markdown, editors and content",
   "path": "tools/content-editors/"
  },
  {
   "label": "PYPI"
  }
 ],
 "primary": {
  "label": "Copy install command",
  "copy": "pip install jinja2"
 },
 "links": [
  {
   "label": "GitHub",
   "href": "https://github.com/pallets/jinja"
  }
 ],
 "track": "New versions, deprecation and license changes on your dashboard",
 "verdicts": [
  {
   "key": "license",
   "label": "License",
   "value": "BSD",
   "status": "yes",
   "sub": "Use it in paid apps",
   "quote": null,
   "note": "License from PyPI classifier.",
   "src": "https://github.com/pallets/jinja"
  },
  {
   "key": "maint",
   "label": "Maintained",
   "value": "Quiet for a year",
   "status": "cond",
   "sub": "Last change Jun 14, 2025",
   "note": "Latest GitHub release Mar 5, 2025. ",
   "src": "https://github.com/pallets/jinja"
  },
  {
   "key": "pop",
   "label": "Used by agents' projects",
   "value": "134 projects",
   "status": "info",
   "sub": "#4 of 149 in its category",
   "note": "Dependency in 134 public GitHub projects set up for AI coding agents that we scanned (2.1%).",
   "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 Jinja2 does",
   "parts": [
    {
     "t": "prose",
     "text": "Jinja is the Pallets project's Python templating engine: templates use near-Python syntax and are compiled to Python code, and the README says a sandboxed environment can safely render untrusted templates."
    }
   ]
  },
  {
   "id": "popularity",
   "nav": "Popularity",
   "h2": "Jinja2 popularity",
   "parts": [
    {
     "t": "stats",
     "items": [
      {
       "n": "79",
       "of": "/ 100",
       "l": "Gid Score, #111 overall"
      },
      {
       "n": "164M",
       "l": "downloads a week, pypi"
      },
      {
       "n": "11.8K",
       "l": "GitHub stars"
      },
      {
       "n": "134",
       "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 Jinja2 is used",
   "parts": [
    {
     "t": "list",
     "items": [
      "Jinja2 is a dependency in 134 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (8.3% of the 1,623 Python ones), #4 of 149 in markdown, editors and content.",
      "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 1,516; those are left out of every share on this page.",
      "The most used alternative in our scan is Mako (13 projects).",
      "Projects that use it most often also use Pydantic (66.4%), Uvicorn (59.7%), FastAPI (59.0%).",
      "It is more common in projects set up for OpenClaw (4.2%) than for Gemini CLI (1.1%)."
     ]
    },
    {
     "t": "h3",
     "text": "By coding agent"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "74 projects, 2.3%",
       "v": "Claude Code",
       "path": "agents/claude-code/"
      },
      {
       "l": "62 projects, 2.0%",
       "v": "GitHub Copilot",
       "path": "agents/github-copilot/"
      },
      {
       "l": "45 projects, 1.8%",
       "v": "Cursor",
       "path": "agents/cursor/"
      },
      {
       "l": "14 projects, 4.2%",
       "v": "OpenClaw",
       "path": "agents/openclaw/"
      },
      {
       "l": "7 projects, 2.5%",
       "v": "Devin Desktop",
       "path": "agents/devin-desktop/"
      },
      {
       "l": "6 projects, 1.3%",
       "v": "OpenAI Codex",
       "path": "agents/openai-codex/"
      },
      {
       "l": "5 projects, 1.5%",
       "v": "OpenCode",
       "path": "agents/opencode/"
      },
      {
       "l": "5 projects, 1.1%",
       "v": "Gemini CLI",
       "path": "agents/gemini-cli/"
      }
     ]
    },
    {
     "t": "h3",
     "text": "Often used with"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "In 66.4% of its projects",
       "v": "Pydantic",
       "path": "tools/pydantic/"
      },
      {
       "l": "In 59.7% of its projects",
       "v": "Uvicorn",
       "path": "tools/uvicorn/"
      },
      {
       "l": "In 59.0% of its projects",
       "v": "FastAPI",
       "path": "tools/fastapi/"
      },
      {
       "l": "In 56.0% of its projects",
       "v": "PyYAML",
       "path": "tools/pyyaml/"
      },
      {
       "l": "In 56.0% of its projects",
       "v": "Requests",
       "path": "tools/requests-py/"
      },
      {
       "l": "In 52.2% of its projects",
       "v": "python-dotenv",
       "path": "tools/python-dotenv/"
      },
      {
       "l": "In 45.5% of its projects",
       "v": "python-multipart",
       "path": "tools/python-multipart/"
      },
      {
       "l": "In 41.8% of its projects",
       "v": "NumPy",
       "path": "tools/numpy/"
      }
     ]
    }
   ]
  },
  {
   "id": "profile",
   "nav": "Profile",
   "h2": "Jinja2 in practice",
   "parts": [
    {
     "t": "h3",
     "text": "Strengths"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "Templates compile to Python code",
       "v": "The README says templates are compiled to optimized Python code. This can happen just-in-time with caching, or ahead-of-time."
      },
      {
       "l": "A sandbox for templates you did not write",
       "v": "The README says a sandboxed environment \"can safely render untrusted templates.\""
      },
      {
       "l": "Layouts through extends and blocks",
       "v": "In the README's example, a page uses <code>{% extends \"base.html\" %}</code> and fills named blocks such as <code>title</code> and <code>content</code>. The README also says you can define macros and import them within templates."
      },
      {
       "l": "Errors point to the template line",
       "v": "The README says exceptions \"point to the correct line in templates to make debugging easier.\""
      }
     ]
    },
    {
     "t": "h3",
     "text": "Watch out for"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "Read the escaping FAQ before rendering HTML",
       "v": "The README says HTML templates \"can use autoescaping to prevent XSS from untrusted user input.\" The docs FAQ has an entry titled \"Why is HTML escaping not the default?\" The answer to that entry is not in the pages reviewed here."
      },
      {
       "l": "3.1.6 was a sandbox security release",
       "v": "The maintainers describe 3.1.6 as a security release. Its listed change is that the <code>|attr</code> filter \"does not bypass the environment's attribute lookup, allowing the sandbox to apply its checks.\" The notes link a GitHub security advisory and say the release \"should not result in breaking changes compared to the latest feature release.\""
      },
      {
       "l": "Application logic belongs in Python \"if possible\"",
       "v": "The README states the philosophy that application logic belongs in Python \"if possible.\" It adds that Jinja \"shouldn't make the template designer's job difficult by restricting functionality too much.\" The docs FAQ also asks \"Isn’t it a bad idea to put logic in templates?\""
      }
     ]
    },
    {
     "t": "h3",
     "text": "A child template that extends a base layout"
    },
    {
     "t": "tabs",
     "label": "Example",
     "items": [
      {
       "tab": "Jinja",
       "code": "{% extends \"base.html\" %}\n{% block title %}Members{% endblock %}\n{% block content %}\n  <ul>\n  {% for user in users %}\n    <li><a href=\"{{ user.url }}\">{{ user.username }}</a></li>\n  {% endfor %}\n  </ul>\n{% endblock %}"
      }
     ]
    }
   ]
  },
  {
   "id": "more",
   "nav": null,
   "spy_as": "profile",
   "h2": "More about Jinja2",
   "parts": [
    {
     "t": "more",
     "items": [
      {
       "title": "Funding",
       "path": "tools/funding/",
       "items": [
        "GitHub Sponsors: https://github.com/pallets",
        "Own page: https://palletsprojects.com/donate",
        "Tidelift: https://tidelift.com/funding/github/pypi/Flask",
        "thanks.dev: https://thanks.dev/u/gh/pallets",
        "31 GitHub sponsors"
       ]
      },
      {
       "title": "Packages around it",
       "items": [
        "pydantic: Data validation",
        "requests: HTTP client",
        "python-dotenv: .env config loading",
        "uvicorn: ASGI server",
        "fastapi: Web API framework",
        "pyyaml: YAML parsing"
       ]
      },
      {
       "title": "More in Markdown, editors and content",
       "path": "tools/content-editors/",
       "items": [
        {
         "text": "react-markdown",
         "path": "tools/react-markdown/"
        },
        {
         "text": "remark-gfm",
         "path": "tools/remark-gfm/"
        },
        {
         "text": "Marked",
         "path": "tools/marked/"
        },
        {
         "text": "gray-matter",
         "path": "tools/gray-matter/"
        },
        {
         "text": "Tiptap",
         "path": "tools/tiptap/"
        },
        {
         "text": "Shiki",
         "path": "tools/shiki/"
        },
        {
         "text": "highlight.js",
         "path": "tools/highlight-js/"
        },
        {
         "text": "markdown-it",
         "path": "tools/markdown-it/"
        }
       ]
      }
     ]
    }
   ]
  },
  {
   "id": "alternatives",
   "nav": "Alternatives",
   "h2": "Alternatives",
   "parts": [
    {
     "t": "alts",
     "items": [
      {
       "name": "Jinja2",
       "me": true,
       "facts": [
        "BSD",
        "Gid 79",
        "164M/wk"
       ]
      },
      {
       "name": "Mako",
       "why": "High-performance Python templating engine with flexible syntax for generating HTML, emails and other text.",
       "path": "tools/mako/",
       "facts": [
        "MIT",
        "Gid 60",
        "59.7M/wk"
       ]
      }
     ],
     "more": "Compare Jinja2 with another tool",
     "more_path": "tools/compare/"
    }
   ]
  },
  {
   "id": "start",
   "nav": "Get started",
   "h2": "Get started",
   "parts": [
    {
     "t": "install",
     "intro": "Install it.",
     "code": "pip install jinja2"
    },
    {
     "t": "h3",
     "text": "Rules for your agent"
    },
    {
     "t": "rules",
     "label": "Paste into AGENTS.md or CLAUDE.md",
     "text": "## Jinja2\n- The latest release in the sources is 3.1.6, which the maintainers call a security release.\n- Editor's recommendation, not from the docs: prefer a version that includes the 3.1.6 change to the `|attr` filter if you use the sandbox.\n- For HTML templates that show untrusted user input, the README says they \"can use autoescaping to prevent XSS\". Read the docs' Autoescaping section and the FAQ entry \"Why is HTML escaping not the default?\" before relying on it.\n- The README says the sandboxed environment \"can safely render untrusted templates\". Editor's recommendation: use it for templates written by users, and read the docs' Sandbox \"Security Considerations\" section.\n- Structure pages with `{% extends %}` and `{% block %}`, as in the README example. Macros can be defined in templates and imported.\n- Follow the README's philosophy: put application logic in Python \"if possible\", and pass the results to the template as data.\n"
    }
   ]
  }
 ],
 "glance": [
  [
   "Package",
   "pypi jinja2"
  ],
  [
   "Category",
   "Markdown, editors and content"
  ],
  [
   "License",
   "BSD"
  ],
  [
   "Latest version",
   "3.1.6, March 5, 2025"
  ],
  [
   "On GitHub since",
   "October 2010"
  ],
  [
   "Gid Score",
   "79.4"
  ],
  [
   "Rank in category",
   "#4 of 149"
  ],
  [
   "GitHub",
   "pallets/jinja"
  ],
  [
   "Last change",
   "Jun 14, 2025"
  ]
 ],
 "good": [],
 "checked_line": "From the package registry, GitHub and our scan of public agent projects; numbers update daily.",
 "logo": "https://agentgid.com/media/avatars/pallets.png"
}