You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

cheerio

Package Overview
Dependencies
Maintainers
2
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cheerio

The fast, flexible & elegant library for parsing and manipulating HTML and XML.

1.1.0
latest
Source
npmnpm
Version published
Weekly downloads
13M
3.13%
Maintainers
2
Weekly downloads
 
Created

What is cheerio?

Cheerio is a fast, flexible, and lean implementation of core jQuery designed specifically for the server. It allows users to manipulate and traverse HTML documents with a familiar jQuery-like API in a Node.js environment.

What are cheerio's main functionalities?

HTML Parsing

Cheerio can parse HTML and allows you to select and manipulate HTML elements in a way similar to jQuery.

const cheerio = require('cheerio');
const $ = cheerio.load('<h2 class="title">Hello world</h2>');
$('h2.title').text('Hello there!');
$('h2').addClass('welcome');
console.log($.html());

DOM Traversal

Cheerio provides methods to traverse the DOM tree, such as selecting elements by class, id, or tag name.

const cheerio = require('cheerio');
const $ = cheerio.load('<ul id="fruits"><li class="apple">Apple</li><li class="orange">Orange</li></ul>');
$('.apple', '#fruits').text();
$('ul .apple').attr('class');

DOM Manipulation

Cheerio allows you to manipulate the DOM by adding, removing, or modifying elements and their attributes.

const cheerio = require('cheerio');
const $ = cheerio.load('<ul id="fruits"></ul>');
$('#fruits').append('<li>Banana</li>');
$('#fruits').prepend('<li>Apple</li>');
$('#fruits').after('<p>Nothing to see here</p>');

Other packages similar to cheerio

Keywords

htmlparser

FAQs

Package last updated on 08 Jun 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts