# Cheerio — card for AI agents

Open-source Node.js library for parsing and querying HTML/XML with a jQuery-like API.

Maker: Cheerio (open source project) · category: Scraping and crawling

## Price (official page)
- Free tier: none listed
- Free tier terms: open source (read from the wording above and the pricing page; empty = not stated)
- Note: Library, not a hosted API: free to use, does not fetch or render JavaScript itself.

## Connect
- npm: `npm install cheerio`
- Repository: https://github.com/cheeriojs/cheerio

## For AI agents on Cheerio (open source project)'s own site (AgentGid check 2026-11-13: 2 of 6)
- llms.txt: none found
- OpenAPI description: none found at the usual places
- Official MCP server: no · official SDK: yes · status page: no
- robots.txt lets AI assistants (ChatGPT-User, Claude-User) read the site: yes

## Price history in AgentGid's catalog (since 2026-10-10)
- Changes recorded: 0 (a vendor price change or an editor's correction; the evidence archive keeps the pricing page of each date)

## Other APIs in this category
- Web Scraper Cloud: https://agentgid.com/apis/webscraper-io/agent.md
- Zyte API: https://agentgid.com/apis/zyte/agent.md
- Scrapfly: https://agentgid.com/apis/scrapfly/agent.md
- Crawl4AI: https://agentgid.com/apis/crawl4ai/agent.md
- Diffbot: https://agentgid.com/apis/diffbot/agent.md

## Links
- AgentGid page: https://agentgid.com/apis/cheerio/


## Cheerio: read and change web page code in JavaScript

Cheerio is a free, open-source code library, not an online service. Your app or script gives it the code of a web page and gets back exactly the parts it asks for, such as product names, prices or links. It can also change that page code, and it runs inside your own program, with no account and no key.

### Where to use it
- Pull prices and names from a page: Read a shop or catalog page your script has downloaded and get each product's name, price and link as a neat list.
- Turn repeated blocks into records: A page lists many similar blocks, like releases, jobs or reviews; describe one block once and get every block back as a record.
- Change page code before saving it: Edit an HTML template or e-mail on the server, for example replace a heading or add a class, then save the result.
- Read a sitemap or feed: Load an XML file such as a sitemap or news feed from a web address and list its entries.
- Clean page text for an AI assistant: Take only the readable text of an article, without scripts and styles, before sending it to a chat model to summarize. (idea, not from the official pages)
- Check your own pages before publishing: In a build step, scan every generated page for images without alt text or pages without a title. (idea, not from the official pages)

### How to start
- Add Cheerio to a Node.js project.

```
npm install cheerio
```

- Load the page code with load, then select elements with CSS selectors, like in jQuery.

```
import * as cheerio from 'cheerio';
const $ = cheerio.load('<h2 class="title">Hello world</h2>');
$('h2.title').text(); // "Hello world"
```

- To have Cheerio download the page itself, use fromURL and await it (Node.js only).

```
import * as cheerio from 'cheerio';
const $ = await cheerio.fromURL('https://example.com');
```


### License
Free for any use, including paid products and client work, under the MIT license. Keep the copyright and license notice with copies of the code; no visible credit is needed.

### Good to know
- It does not run the page's scripts. Content that a site builds in the browser will be missing; use a real browser tool like Playwright for those sites.
- It does not make page code safe. Clean scraped code with a sanitizer before you show it on your own site.
- Version 1.2.0 needs Node.js 20.18.1 or newer; the docs already state 22.19 or newer for the next version.
- In the browser only load works; downloading pages and reading files need Node.js.
- If users can type the address to fetch, check it first, or attackers can make your server open internal addresses.

Checked 2026-11-10 against: https://cheerio.js.org, https://cheerio.js.org/docs/intro, https://cheerio.js.org/docs/basics/loading, https://cheerio.js.org/docs/basics/selecting, https://cheerio.js.org/docs/basics/traversing, https://cheerio.js.org/docs/basics/manipulation, https://cheerio.js.org/docs/basics/extract, https://cheerio.js.org/docs/basics/troubleshooting, https://cheerio.js.org/docs/advanced/configuring-cheerio, https://cheerio.js.org/docs/advanced/security, https://github.com/cheeriojs/cheerio/blob/main/Readme.md, https://github.com/cheeriojs/cheerio/blob/main/LICENSE, https://raw.githubusercontent.com/cheeriojs/cheerio/main/package.json, https://registry.npmjs.org/cheerio/latest, https://registry.npmjs.org/cheerio/-/cheerio-1.2.0.tgz

### Mistakes to avoid
- Don't: Using Cheerio on a site whose content is drawn by React or Vue in the browser, then reading empty results as "no data". → Do: Check $.html() first; if you see an empty root div and a script bundle, render the page with Playwright or Puppeteer and pass that HTML to Cheerio. (Cheerio does not run scripts, so content built in the browser is not in the HTML it got.)
- Don't: $('#greeting').html(`Hello, ${name}`) with text typed by a user → Do: $('#greeting').text(`Hello, ${name}`) (html() and other insert methods parse their input as markup, so user text can inject tags; text() escapes it.)
- Don't: $(`[data-id="${id}"]`) with an id from user input or scraped data → Do: $('[data-id]').filter((_, el) => $(el).attr('data-id') === id) (A quote in the value breaks out of the selector; Cheerio has no CSS.escape.)
- Don't: cheerio.fromURL(url, { requestOptions: { headers: { ... } } }) → Do: Always include method: 'GET' in requestOptions, and repeat the Accept header if you set headers. (requestOptions has no default method, and your headers replace Cheerio's defaults instead of adding to them.)
- Don't: $('li').text() to get each item → Do: $('li').map((i, el) => $(el).text()).get() (text() on many elements joins them into one run-on string with no separator.)

### Questions
- Do I need an account or a key? No. Cheerio is a code library you install; nothing is sent to a Cheerio service.
- Why is my selection empty on some sites? The content is probably built by the page's scripts, which Cheerio does not run. Check the HTML you received; for such pages use Puppeteer or Playwright.
- Can I use it in a commercial product? Yes. It is MIT licensed; keep the license notice with copies of the code.
- Does it work in the browser? Yes, with the load function only; fetching and stream loaders need Node.js.

---
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.
