jsdom: JavaScript web standards implementation for Node.js
Pure JavaScript implementation of web standards for Node.js.
Learn more about jsdom
jsdom is a pure JavaScript implementation of web standards that provides a DOM and HTML parser for Node.js environments. It recreates browser APIs including the Document Object Model, HTML5 Canvas, and Web Storage by implementing WHATWG standards entirely in JavaScript without requiring a headless browser. The library parses HTML markup into a traversable and manipulable document object model, exposing the same APIs that browsers provide such as querySelector, innerHTML manipulation, and event handling. It supports configurable resource loading, script execution contexts, and can simulate various browser behaviors including cookie management and navigation. The implementation prioritizes standards compliance and API compatibility over rendering performance, making it suitable for server-side DOM manipulation, testing, and web scraping scenarios.
Pure JavaScript Implementation
Built entirely in JavaScript with zero native dependencies or binary compilation. Installs consistently across all platforms and Node.js versions without build toolchains or platform-specific complications.
Sandboxed Script Execution
Executes embedded JavaScript in isolated contexts where scripts interact with the simulated DOM. Enables testing of client-side behavior in Node.js environments without spawning browser processes.
WHATWG Standards Compliance
Implements official DOM and HTML specifications with familiar browser APIs like querySelector and addEventListener. Browser code runs in Node.js without rewriting, enabling consistent testing and server-side rendering.
const dom = new JSDOM(`<!DOCTYPE html><p>Hello world</p>`);
console.log(dom.window.document.querySelector("p").textContent); // "Hello world"Adds CSS nesting and container query CSSOM classes; fixes @import stylesheet exposure in CSSOM tree.
- –Use new CSSGroupingRule, CSSNestedDeclarations, CSSConditionRule, CSSContainerRule, CSSScopeRule, CSSSupportsRule, and layer rule classes.
- –Verify @import stylesheets now appear correctly in CSSOM without overwriting parent link or style element sheets.
Switches CSS parser to @acemir/cssom for nested selectors and layer statements; fixes selector cache invalidation and corrects package.json engines field.
- –Upgrade to @acemir/cssom parser to gain nested CSS selectors, nested declarations, layer statements, and improved at-rule validation.
- –Verify package.json engines field now correctly reflects minimum Node.js versions required (see v27.0.1 changelog for specifics).
Patch release inadvertently raises minimum Node.js to v20.19.0+, v22.12.0+, or v24.0.0+ via dependency update; pin to v26.1.0 if using earlier versions.
- –Pin jsdom to v26.1.0 if running Node.js v20.0–v20.18, v22.0–v22.11, or encountering ERR_REQUIRE_ESM errors.
- –Fixes CSS selector regressions including class attribute change handling; most fixes available in v27.0.0 via dependency updates.
Top in Developer Tools
Related Repositories
Discover similar tools and frameworks used by developers
colima
Lima-based container runtime provisioning for macOS and Linux.
husky
Manage Git hooks via Node.js package.
grafana
Query and visualize metrics from multiple data sources.
node-gyp
Compiles native C/C++ addons for Node.js.
PyMuPDF
Python bindings for MuPDF document processing library.