🛠️
Utility7M+/wkMIT

cheerio

Cheerio is a fast, flexible, and lean implementation of jQuery designed specifically for server-side HTML parsing and manipulation. Cheerio parses HTML document

Installation

npm
npm install cheerio
yarn
yarn add cheerio
pnpm
pnpm add cheerio

Import

ESM
import * as cheerio from 'cheerio';

Quick Example

usage
import * as cheerio from 'cheerio';

const html = '<h2 class="title">Hello</h2><p>World</p>';
const $ = cheerio.load(html);

console.log($('h2').text()); // 'Hello'
console.log($('.title').attr('class')); // 'title'

About cheerio

Cheerio is a fast, flexible, and lean implementation of jQuery designed specifically for server-side HTML parsing and manipulation. Cheerio parses HTML documents into a DOM-like structure and provides jQuery's familiar API for traversing, selecting, and manipulating elements without the overhead of a full browser environment. Using CSS selectors with the $() function, you can find elements, read and modify attributes, extract text content, manipulate classes, and restructure HTML documents. Cheerio is commonly used for web scraping — extracting data from HTML pages by selecting elements and reading their content. The library handles malformed HTML gracefully using parse5 or htmlparser2 as underlying parsers, making it robust for processing real-world web pages. Cheerio supports XML parsing mode for working with RSS feeds and other XML documents. Unlike jsdom which creates a full browser environment with window, document, and event handling, Cheerio focuses exclusively on DOM manipulation without JavaScript execution, making it significantly faster and lighter. Cheerio is the standard tool for server-side HTML manipulation in the Node.js ecosystem.

Quick Facts

Packagecheerio
CategoryUtility
Weekly Downloads7M+
LicenseMIT
Installnpm install cheerio

Related Packages

Browse npm Packages by Category

Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.