{
 "kind": "tool",
 "slug": "lxml",
 "path": "tools/lxml/",
 "name": "lxml",
 "maker": null,
 "density": "profile",
 "crumbs": [
  [
   "Tools",
   "tools/"
  ],
  [
   "Scraping, browsers and parsing",
   "tools/scraping-parsing/"
  ]
 ],
 "lead": "High-performance XML and HTML processing library combining libxml2/libxslt with Python.",
 "chips": [
  {
   "label": "Scraping, browsers and parsing",
   "path": "tools/scraping-parsing/"
  },
  {
   "label": "PYPI"
  }
 ],
 "primary": {
  "label": "Copy install command",
  "copy": "pip install lxml"
 },
 "links": [
  {
   "label": "GitHub",
   "href": "https://github.com/lxml/lxml"
  },
  {
   "label": "Website",
   "href": "https://lxml.de/"
  }
 ],
 "track": "New versions, deprecation and license changes on your dashboard",
 "verdicts": [
  {
   "key": "license",
   "label": "License",
   "value": "BSD-3-Clause",
   "status": "yes",
   "sub": "Use it in paid apps",
   "quote": null,
   "note": "License from PyPI license field.",
   "src": "https://github.com/lxml/lxml"
  },
  {
   "key": "maint",
   "label": "Maintained",
   "value": "Maintained",
   "status": "yes",
   "sub": "Last change Nov 23, 2026",
   "note": "Latest GitHub release Sep 2, 2026. ",
   "src": "https://github.com/lxml/lxml"
  },
  {
   "key": "pop",
   "label": "Used by agents' projects",
   "value": "79 projects",
   "status": "info",
   "sub": "#4 of 141 in its category",
   "note": "Dependency in 79 public GitHub projects set up for AI coding agents that we scanned (1.3%).",
   "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 lxml does",
   "parts": [
    {
     "t": "prose",
     "text": "lxml puts the C libraries libxml2 and libxslt behind a Python API modeled on ElementTree, and its README publishes a candid income report: well over 250 million downloads a month, EUR 3868.43 of project income in 2025."
    }
   ]
  },
  {
   "id": "popularity",
   "nav": "Popularity",
   "h2": "lxml popularity",
   "parts": [
    {
     "t": "stats",
     "items": [
      {
       "n": "72",
       "of": "/ 100",
       "l": "Gid Score, #305 overall"
      },
      {
       "n": "97.5M",
       "l": "downloads a week, pypi"
      },
      {
       "n": "3,077",
       "l": "GitHub stars"
      },
      {
       "n": "79",
       "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 lxml is used",
   "parts": [
    {
     "t": "list",
     "items": [
      "lxml is a dependency in 79 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (4.9% of the 1,623 Python ones), #4 of 141 in scraping, browsers and parsing.",
      "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 933; those are left out of every share on this page.",
      "The most used alternative in our scan is Beautiful Soup (133 projects).",
      "Projects that use it most often also use Beautiful Soup (70.9%), Requests (60.8%), python-dotenv (58.2%)."
     ]
    },
    {
     "t": "h3",
     "text": "By coding agent"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "42 projects, 1.3%",
       "v": "Claude Code",
       "path": "agents/claude-code/"
      },
      {
       "l": "37 projects, 1.2%",
       "v": "GitHub Copilot",
       "path": "agents/github-copilot/"
      },
      {
       "l": "27 projects, 1.1%",
       "v": "Cursor",
       "path": "agents/cursor/"
      },
      {
       "l": "5 projects, 1.5%",
       "v": "OpenClaw",
       "path": "agents/openclaw/"
      }
     ]
    },
    {
     "t": "h3",
     "text": "Often used with"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "In 70.9% of its projects",
       "v": "Beautiful Soup",
       "path": "tools/beautifulsoup4/"
      },
      {
       "l": "In 60.8% of its projects",
       "v": "Requests",
       "path": "tools/requests-py/"
      },
      {
       "l": "In 58.2% of its projects",
       "v": "python-dotenv",
       "path": "tools/python-dotenv/"
      },
      {
       "l": "In 46.8% of its projects",
       "v": "Pydantic",
       "path": "tools/pydantic/"
      },
      {
       "l": "In 43.0% of its projects",
       "v": "Uvicorn",
       "path": "tools/uvicorn/"
      },
      {
       "l": "In 41.8% of its projects",
       "v": "Pillow",
       "path": "tools/pillow/"
      },
      {
       "l": "In 40.5% of its projects",
       "v": "FastAPI",
       "path": "tools/fastapi/"
      },
      {
       "l": "In 39.2% of its projects",
       "v": "NumPy",
       "path": "tools/numpy/"
      }
     ]
    }
   ]
  },
  {
   "id": "profile",
   "nav": "Profile",
   "h2": "lxml in practice",
   "parts": [
    {
     "t": "h3",
     "text": "Strengths"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "C engines, ElementTree-shaped API",
       "v": "The maintainers say lxml combines the speed and XML feature completeness of libxml2 and libxslt with a native Python API. That API is mostly compatible with ElementTree, so ElementTree tutorials largely carry over."
      },
      {
       "l": "Several schema languages for validation",
       "v": "The docs cover validation at parse time and validation against DTD, RelaxNG, XML Schema and Schematron, all in the same library as XPath and XSLT."
      },
      {
       "l": "Python functions inside XPath and XSLT",
       "v": "You can call your own Python code from XPath expressions and XSLT stylesheets through extension functions."
      },
      {
       "l": "Several HTML parsers to choose from",
       "v": "Besides <code>lxml.html</code>, the docs describe a BeautifulSoup-backed <code>soupparser</code>. It can serve as a fallback or for encoding detection only. There is also an html5lib parser."
      }
     ]
    },
    {
     "t": "h3",
     "text": "Watch out for"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "XML Schema support has gaps",
       "v": "Standards compliance depends on libxml2 and libxslt. The FAQ says libxml2's XML Schema support is not complete."
      },
      {
       "l": "XPath 1.0 and XSLT 1.0",
       "v": "The FAQ's list of implemented standards names XPath 1.0 and XSLT 1.0, plus EXSLT. Plan your expressions and stylesheets around those versions."
      },
      {
       "l": "Not a perfect ElementTree clone",
       "v": "The FAQ admits there are places where lxml cannot match ElementTree behavior. These are listed in a separate compatibility document."
      }
     ]
    }
   ]
  },
  {
   "id": "more",
   "nav": null,
   "spy_as": "profile",
   "h2": "More about lxml",
   "parts": [
    {
     "t": "more",
     "items": [
      {
       "title": "Funding",
       "path": "tools/funding/",
       "items": [
        "GitHub Sponsors: https://github.com/scoder",
        "Tidelift: https://tidelift.com/funding/github/pypi/lxml",
        "22 GitHub sponsors"
       ]
      },
      {
       "title": "Head to head",
       "items": [
        {
         "text": "Beautiful Soup vs lxml",
         "note": "used together in 56 projects",
         "path": "tools/compare/beautiful-soup-vs-lxml/"
        }
       ]
      },
      {
       "title": "Packages around it",
       "items": [
        "beautifulsoup4: HTML parsing",
        "requests: HTTP client",
        "python-dotenv: .env config loading",
        "pydantic: data validation",
        "numpy: numeric arrays",
        "aiohttp: async HTTP client/server"
       ]
      },
      {
       "title": "More in Scraping, browsers and parsing",
       "path": "tools/scraping-parsing/",
       "items": [
        {
         "text": "Puppeteer",
         "path": "tools/puppeteer/"
        },
        {
         "text": "Playwright Core",
         "path": "tools/playwright-core/"
        },
        {
         "text": "Playwright (Python)",
         "path": "tools/playwright/"
        },
        {
         "text": "Cheerio",
         "path": "tools/cheerio/"
        },
        {
         "text": "fast-xml-parser",
         "path": "tools/fast-xml-parser/"
        },
        {
         "text": "jsonc-parser",
         "path": "tools/jsonc-parser/"
        },
        {
         "text": "Mozilla Readability",
         "path": "tools/mozilla-readability/"
        },
        {
         "text": "linkedom",
         "path": "tools/linkedom/"
        }
       ]
      }
     ]
    }
   ]
  },
  {
   "id": "alternatives",
   "nav": "Alternatives",
   "h2": "Alternatives",
   "parts": [
    {
     "t": "alts",
     "items": [
      {
       "name": "lxml",
       "me": true,
       "facts": [
        "BSD-3-Clause",
        "Gid 72",
        "97.5M/wk"
       ]
      },
      {
       "name": "Beautiful Soup",
       "why": "Python HTML/XML parsing and screen-scraping library for web data extraction.",
       "path": "tools/beautifulsoup4/",
       "facts": [
        "MIT",
        "Gid 78",
        "76.1M/wk"
       ]
      },
      {
       "name": "html5lib",
       "why": "HTML parser based on WHATWG specification for parsing and processing HTML.",
       "path": "tools/html5lib/",
       "facts": [
        "MIT",
        "Gid 56",
        "6.9M/wk"
       ]
      }
     ],
     "more": "Compare lxml with another tool",
     "more_path": "tools/compare/"
    }
   ]
  },
  {
   "id": "start",
   "nav": "Get started",
   "h2": "Get started",
   "parts": [
    {
     "t": "install",
     "intro": "Install it.",
     "code": "pip install lxml"
    },
    {
     "t": "h3",
     "text": "Rules for your agent"
    },
    {
     "t": "rules",
     "label": "Paste into AGENTS.md or CLAUDE.md",
     "text": "## lxml\n- Import the main module with `from lxml import etree`; the FAQ's examples assume it.\n- Write against the ElementTree API first. Use lxml-only features (XPath, XSLT, Relax NG, XML Schema, c14n) when needed, knowing they tie the code to lxml.\n- Keep XPath expressions and XSLT stylesheets to XPath 1.0 and XSLT 1.0, the versions in the FAQ's standards list.\n- Do not assume complete XML Schema validation: the FAQ says libxml2's support \"is currently not 100% complete\".\n- Before parsing untrusted input or exposing lxml in a web service, read the FAQ entries \"Is lxml vulnerable to XML bombs?\" and \"How do I use lxml safely as a web-service endpoint?\".\n- Before sharing XSLT stylesheets across threads, read the FAQ's Threading section (\"Why can't I reuse XSLT stylesheets in other threads?\").\n- Report bugs on Launchpad (bugs.launchpad.net/lxml), the issue tracker the README points to.\n"
    }
   ]
  }
 ],
 "glance": [
  [
   "Package",
   "pypi lxml"
  ],
  [
   "Category",
   "Scraping, browsers and parsing"
  ],
  [
   "License",
   "BSD-3-Clause"
  ],
  [
   "Latest version",
   "lxml-6.1.3-1, September 2, 2026"
  ],
  [
   "On GitHub since",
   "February 2011"
  ],
  [
   "Gid Score",
   "72.2"
  ],
  [
   "Rank in category",
   "#4 of 141"
  ],
  [
   "GitHub",
   "lxml/lxml"
  ],
  [
   "Last change",
   "Nov 23, 2026"
  ]
 ],
 "good": [
  "Used by cssutils, as listed by the source; we have not checked each one."
 ],
 "checked_line": "From the package registry, GitHub and our scan of public agent projects; numbers update daily.",
 "logo": "https://agentgid.com/media/avatars/lxml.png"
}