cheeriojs

cheerio: Parse and Manipulate HTML and XML

Cheerio is a TypeScript library for parsing HTML and XML and working with documents through a jQuery-style API. Use it to select, traverse, edit, and render markup without relying on a browser DOM.

View on GitHub Compare
Stars
30.5k
Forks
1.7k
Stars, last 30 days
+23

Our take

Health score

67/100

How it is scored
Activity
65
Community
72
Issues
46
Pull requests
84

+23 stars in the last 30 days

  • Merges more pull requests than 96% of the projects we track
  • More contributors than 78% of the projects we track

Project history

Daily GitHub snapshots since Oct 7, 2026. History covers stars and forks; health signals are not tracked historically.

Selected snapshot

Stars

30,541

Forks

1,751

Change since Nov 16, 2026: +1 stars·+1 forks

Overview

Cheerio loads HTML or XML into a lightweight document model that JavaScript and TypeScript programs can query and modify. It provides a familiar, jQuery-style API without the browser-specific DOM behavior, making it useful for server-side markup processing.

Choose Cheerio when a task involves manipulating document structure or extracting data from markup. It is a parsing and document-processing library, not a browser automation tool; its README describes HTML parsing through parse5 and optional use of htmlparser2.

Key Features

  • Load HTML or XML strings into a document that can be queried and edited.
  • Find elements using jQuery-style selectors and scoped contexts.
  • Read and update text, attributes, classes, and element content.
  • Traverse and manipulate a DOM-like node structure.
  • Render the full document, selected elements, or text content.
  • Use parse5 for HTML parsing or optionally choose htmlparser2.
  • Supports JavaScript and TypeScript usage, with installation options for npm, Bun, and Deno.

Use Cases

  • Web developers can extract structured information from downloaded HTML in a Node.js data-processing task.
  • Backend developers can transform or clean HTML fragments before storing or publishing them.
  • Test and build-tool authors can select elements and inspect or rewrite markup without launching a browser.
  • XML-processing workflows can use the same document-selection and manipulation approach for XML input.

Getting Started

Install with npm:

npm install cheerio

See the README for usage details and alternative package-manager commands.

Considerations

  • Cheerio works with its own lightweight document model rather than a full browser environment, so it is not a substitute for browser rendering or browser automation.
  • Its API implements a subset of jQuery, not the entire jQuery library.
  • Parsing behavior can depend on the selected parser. The README identifies parse5 as the HTML parser and htmlparser2 as an optional alternative.

Found this useful?

Share it with someone who would like cheerio.