Use this file to discover Exa products, pricing, evaluations, comparisons, use cases, agent interfaces, and technical documentation before exploring further.
JavaScript HTML parser libraries turn HTML text into a tree of nodes that code can query, change, and serialize. A full DOM implementation exposes browser APIs such as querySelector, while a lighter parser returns a plain tree or a stream of parse events. These libraries extract data from scraped pages, transform HTML in build pipelines, and run browser-style tests.
Popularity
parse5 has the most monthly downloads in this comparison, at 910.8M.
function resolveUrls(root, baseUrl) {
for (const a of root.querySelectorAll("a[href]")) {
const href = a.getAttribute("href");
if (!href || /^(https?:|mailto:|tel:|javascript:|#)/i.test(href)) continue;
try {
a.setAttribute("href", new URL(href, baseUrl).toString());
} catch {}
}
for (const img of root.querySelectorAll("img[src]")) {
const src = img.getAttribute("src");
if (!src) {
img.remove();
continue;
}
if (src.startsWith("data:")) {
img.remove();
continue;
}
const resolvedSrc = /^https?:/i.test(src)
? src
: (() => {
try {
return new URL(src, baseUrl).toString();
} catch {
return src;
}
})();
if (IGNORED_IMG_BASEPATHS.some((base) => resolvedSrc.startsWith(base))) {
img.remove();
continue;
}
if (!/^https?:/i.test(src)) {
try {
img.setAttribute("src", new URL(src, baseUrl).toString());
} catch {}
}
const alt = (img.getAttribute("alt") || "").trim();
if (!alt) {
try {
const pathname = new URL(img.getAttribute("src")).pathname;
const filename = pathname.split("/").pop() || "image";
img.setAttribute("alt", filename);
} catch {
img.setAttribute("alt", "image");
}
}
}
}
FAQ
parse5 follows the HTML Living Standard and fits code that needs browser-accurate trees. Cheerio adds a jQuery-like API for selecting and editing elements. jsdom and Happy DOM supply a DOM with browser APIs, while htmlparser2 emits parse events as markup arrives.
Cheerio parses HTML and XML and gives a jQuery-like API for traversing and changing the result. It does not render pages, load external resources, or run JavaScript.
jsdom is a pure-JavaScript implementation of the WHATWG DOM and HTML standards for Node.js. It returns zeros for many layout properties and does not navigate when location.href changes.
Cheerio parses markup into a tree with a jQuery-like API and skips rendering, CSS, and scripts. jsdom builds a browser-style DOM, with objects such as window and document.querySelector.
Happy DOM implements a web browser without a graphical interface, including many WHATWG DOM and HTML standards. It works as a test environment for tools such as Vitest and Jest, and it runs scripts only when JavaScript evaluation is turned on.
No. Content that client-side scripts render never reaches Cheerio's tree, because Cheerio does not run JavaScript.
For coding agents
Found your HTML parser library? Help your agent use it.
Connect Exa so your coding agent can find the library’s documentation, check its API, and look up implementations while you build.