Navigate:
~$JSDOM0.0%

jsdom: JavaScript web standards implementation for Node.js

Pure JavaScript implementation of web standards for Node.js.

LIVE RANKINGS • 06:52 AM • STEADY
OVERALL
#209
27
DEVELOPER TOOLS
#42
7
30 DAY RANKING TREND
ovr#209
·Devel#42
STARS
21.4K
FORKS
1.8K
DOWNLOADS
31.6M
7D STARS
+8
7D FORKS
+1
See Repo:
Share:

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.


1

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.

2

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.

3

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"

v27.2.0

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.
v27.1.0

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).
v27.0.1

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.


[ EXPLORE MORE ]

Related Repositories

Discover similar tools and frameworks used by developers