# Cheerio — card for AI agents

jQuery-like syntax for parsing and manipulating HTML/XML with server-side speed.

Category: Scraping, browsers and parsing · npm package `cheerio` · latest version 1.2.0 (checked 2026-11-01)
Install: `npm install cheerio`
License: MIT (permissive)

In your own product (generator, app, hosted service): **yes**. Permissive license: ship it inside your own product, closed or open source, and keep its license and copyright notice.

## Rules for AI agents (paste into AGENTS.md or CLAUDE.md)

## Cheerio
- Import with `import * as cheerio from 'cheerio'` in ESM or TypeScript, and `const cheerio = require('cheerio')` elsewhere.
- Always call `cheerio.load(html)` first. There is no implicit document like jQuery's.
- Query with `$(selector, [context], [root])`. `context` scopes the search, as in `$('.apple', '#fruits')`.
- Only a subset of core jQuery exists. Check the docs before using a jQuery method.
- `$.html()` and `$.root().html()` render a full document with `` added. Use `$(sel).prop('outerHTML')` for one element's markup.
- Use `.text()` for text content. Rely only on the node properties the README lists: `tagName`, `parentNode`, `previousSibling`, `nextSibling`, `nodeValue`, `firstChild`, `childNodes`, `lastChild`.

## What it is
- Cheerio is an MIT-licensed npm library for parsing and manipulating HTML and XML. The GitHub repository was created on 2011-10-09. Its pitch is familiarity: the README says it "implements a subset of core jQuery" with the browser-specific parts stripped out.
- You hand it markup with `cheerio.load()` and get back a `$` function. You then select elements with jQuery-style selectors, change them, and render the result back to HTML or text. Under the hood it uses parse5 for HTML, and it can optionally switch to htmlparser2. The README says it runs in both browser and server environments.
- The project website pitches it to developers who want to parse, manipulate and render HTML from JavaScript. That covers scraping pipelines and server-side HTML rewriting. It is most natural for people who already think in jQuery.

## Caveats
- Not all of jQuery: Cheerio implements only a subset of core jQuery. Do not assume every jQuery method you know is present.
- There is no ambient document: jQuery works on the page's built-in DOM. Cheerio has none, so every document must be passed to `cheerio.load()` first.
- Fragments come back wrapped: The README examples show that loading a fragment and calling `$.html()` returns it wrapped in `<html><head></head><body>`. For a single element's markup, the README uses `.prop('outerHTML')` instead.
- Nodes only resemble browser DOM nodes: Collection items bear "some resemblance" to browser DOM nodes. The README lists only a fixed set of properties, such as `tagName`, `parentNode` and `childNodes`.

## Numbers (AgentGid data)
- Gid Score: 78.2 (#132 of all tools, 4 of 141 in its category)
- Used in 76 public projects set up for AI coding agents (1.2%)
- Downloads last week: 37,434,618 (as of 2026-11-24), +35.8% over 4 weeks
- GitHub stars: 30,553 (as of 2026-11-24)
- Last push: 2026-11-24

## Often used with
Axios 44.7%, dotenv 47.4%, TypeScript 81.6%, Tailwind CSS 59.2%, Zod 50.0%, React 55.3%

## Checked alternatives (same job)
- Puppeteer: https://agentgid.com/tools/puppeteer/agent.md
- linkedom: https://agentgid.com/tools/linkedom/agent.md
- parse5: https://agentgid.com/tools/parse5/agent.md
- xml2js: https://agentgid.com/tools/xml2js/agent.md

## Links
- AgentGid page: https://agentgid.com/tools/cheerio/
- Homepage: https://cheerio.js.org/
- Repository: https://github.com/cheeriojs/cheerio
- Source: https://github.com/cheeriojs/cheerio#readme
- Source: https://github.com/cheeriojs/cheerio
- Source: https://github.com/cheeriojs/cheerio/releases
- Source: https://cheerio.js.org

---
AgentGid's catalog is curated: every entry was checked against the maker's official pages (registry, repository, license and pricing pages) on the date shown; a license value shows the quote it stands on wherever AgentGid has one. Usage numbers come from AgentGid's own scan of public repositories set up for AI coding agents. Claims by makers are reported, not tested by AgentGid.
