Cheerio

The fast, flexible library for parsing and manipulating HTML and XML with a familiar jQuery-style API.

Library
npm
v1.2.0
30,529 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
90 /100 Excellent
Development Activity 100
Maintenance 84
Community 76
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
89 /100 Excellent
Architecture 92
Code Quality 90
Innovation 85
Learning Curve 90

Cheerio implements a subset of core jQuery designed specifically for the server, giving Node.js and browser developers a familiar, expressive API for parsing, traversing, and manipulating HTML and XML documents without the overhead of a full browser environment. It wraps parse5 for spec-compliant parsing (with an optional forgiving htmlparser2 mode) and operates directly against a lightweight DOM model, making it dramatically faster than driving a real browser or headless DOM implementation for the same job.

Widely used as the parsing layer inside web scrapers, static site generators, RSS/feed processors, and server-side rendering pipelines, Cheerio is a foundational dependency across the JavaScript scraping and content-processing ecosystem. Version 1.x ships full TypeScript types, dual ESM/CommonJS builds, and a slim entry point for bundle-size-sensitive environments.

What You Get

  • A cheerio.load() entry point that parses an HTML or XML string into a queryable, mutable document
  • A jQuery-compatible subset of selector, traversal, and manipulation methods (.find(), .attr(), .text(), .html(), .css(), .each(), and more)
  • Pluggable parsing backends — the spec-compliant parse5 parser by default, or the forgiving, faster htmlparser2 parser via the xmlMode and parser options
  • First-class TypeScript types, dual ESM/CommonJS builds, and a cheerio/slim entry point for smaller bundles

Common Use Cases

  • Scraping and extracting structured data from HTML pages fetched via fetch, undici, or another HTTP client
  • Server-side templating and post-processing of HTML output before it’s sent to the client
  • Parsing RSS/Atom feeds or other XML documents with xmlMode enabled
  • Asserting against rendered HTML output in unit and integration tests

Under The Hood

Architecture Cheerio’s execution flow begins in src/load.ts, which normalizes CheerioOptions (src/options.ts) and hands the input HTML/XML string to a pluggable parser via src/parsers/parse5-adapter.ts (or htmlparser2 directly in xmlMode), producing a domhandler-based node tree. That tree is wrapped by src/cheerio.ts’s abstract Cheerio class, which mixes in six method modules — src/api/traversing.ts, manipulation.ts, attributes.ts, css.ts, forms.ts, and extract.ts — via a MethodsType intersection, so the public $ object is a static factory (src/static.ts) plus this composed instance prototype. Serialization back to a string goes through dom-serializer, and selector matching is delegated to the separate cheerio-select package (itself built on css-select), keeping selection, DOM representation, and rendering as cleanly separated concerns.

Tech Stack Cheerio is TypeScript-first, targeting ES2019 with Node16 module resolution per tsconfig.json, and depends on a small, well-factored set of single-purpose packages: parse5 plus parse5-htmlparser2-tree-adapter/parse5-parser-stream for spec-compliant parsing, htmlparser2 for the forgiving fallback, domhandler/domutils/dom-serializer for the DOM model, cheerio-select for CSS selector matching, encoding-sniffer and whatwg-mimetype for charset/MIME detection, and undici for the optional fromURL HTTP fetch. Builds are produced as dual ESM/CommonJS output (dist/esm, dist/commonjs) via the package.json exports map, with a browser-specific entry (index-browser.mts) and a dependency-light cheerio/slim build for bundle-conscious consumers.

Code Quality The src tree pairs nearly every module with a co-located .spec.ts file (14 spec files covering cheerio.ts, load.ts, parse.ts, options.ts, static.ts, utils.ts, and each src/api/.ts module), run via Vitest per vitest.config.ts, with Biome (biome.json) and an ESLint flat config (eslint.config.js) enforcing style. Public methods carry structured TSDoc comments with @example blocks (visible throughout src/load.ts and src/cheerio.ts), strict TypeScript is enabled project-wide (strict: true, isolatedDeclarations: true in tsconfig.json), and the project publishes a SECURITY.md/THREAT_MODEL.md/INCIDENT_RESPONSE.md trio — an unusually mature process footprint for a library of its size.

API Design Cheerio’s headline design choice is deliberately mirroring jQuery’s $(selector) API, so anyone with browser-jQuery experience is productive immediately — cheerio.load(html) returns a bound $ with .find(), .attr(), .text(), .css(), .each(), and more. Getting started requires only one line (const $ = cheerio.load(html)) with no configuration, while power users can opt into xmlMode, a custom parser, or the cheerio/slim build without touching core call sites — a low floor for beginners paired with enough surface area across six method modules for advanced DOM manipulation without boilerplate.

Used by 45 apps in this directory

TypeScript
84%
Apache 2.0

Continue

AI Code Assistants · AI Development · Automation

36,303

Open-source coding agent for VS Code, JetBrains, and CLI with support for 30+ LLM providers.

View details
66
Repo Health
88
Technical
62
Dependency
Built with
TypeScript 84%
Updated 1 weeks ago
TypeScript
95%
AGPL 3.0

Docmost

CMS · Collaboration · Note Taking

22,079

Self-hosted collaborative wiki and knowledge base with real-time editing, diagrams, AI assistance, and enterprise access controls — a modern alternative to Confluence and Notion.

View details
89
Repo Health
70
Technical
66
Dependency
Built with
TypeScript 95%
Updated 6 days ago
TypeScript
91%
Other

FastGPT

AI Agents · AI Development

29,900

Build, debug, and deploy knowledge-based AI agents with a visual workflow editor, RAG retrieval, and support for any OpenAI-compatible LLM.

View details
93
Repo Health
84
Technical
66
Dependency
Built with
TypeScript 91%
Updated 6 days ago
TypeScript
72%
AGPL 3.0

Firecrawl

AI Development · Developer Tools

194,745

Turn any website into clean, LLM-ready data with a single API call — no proxy headaches, no scraping complexity.

View details
89
Repo Health
83
Technical
65
Dependency
Built with
TypeScript 72%
Python 12%
Updated 6 days ago
TypeScript
62%
Other

Flowise

AI Development · Automation · Developer Tools

55,521

Drag-and-drop visual builder for AI agents, RAG pipelines, and multi-agent systems—deploy anywhere in minutes.

View details
75
Repo Health
77
Technical
63
Dependency
Built with
TypeScript 62%
JavaScript 27%
Updated 2 months ago
TypeScript
63%
MIT

Ghost

Blogging · CMS

55,598

Open source headless Node.js CMS for professional publishing, paid memberships, and newsletters with a fully owned audience.

View details
96
Repo Health
85
Technical
64
Dependency
Built with
TypeScript 63%
JavaScript 35%
Updated 1 weeks ago
TypeScript
79%
AGPL 3.0

Ghostfolio

Invoicing Finance

9,565

Track your stocks, ETFs, and crypto with a privacy-first, self-hostable wealth management platform built for data-driven investors.

View details
93
Repo Health
79
Technical
67
Dependency
Built with
TypeScript 79%
HTML 19%
Updated 1 weeks ago
TypeScript
62%
EPL-2.0

Huly Platform

Collaboration · Project Management · Team Chat

27,978

Open-source all-in-one workspace that replaces Linear, Jira, Slack, and Notion for product and engineering teams.

View details
90
Repo Health
86
Technical
62
Dependency
Built with
TypeScript 62%
Svelte 34%
Updated 1 weeks ago
TypeScript
98%
AGPL 3.0

Karakeep

Bookmarks Archiving

29,926

Self-hosted bookmark manager that captures links, notes, images, and PDFs with AI tagging, full-text search, and automatic archiving.

View details
88
Repo Health
76
Technical
66
Dependency
Built with
TypeScript 98%
Updated 1 weeks ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers