Navigate:
~$JSDOM0.1%

jsdom: JavaScript web standards implementation for Node.js

Pure JavaScript implementation of web standards for Node.js.

LIVE RANKINGS • 12:29 PM • STEADY
OVERALL
#333
69
DEVELOPER TOOLS
#69
20
30 DAY RANKING TREND
ovr#333
·Devel#69
STARS
21.5K
FORKS
1.8K
7D STARS
+23
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.

jsdom

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 jsdom = require("jsdom");
const { JSDOM } = jsdom;

const dom = new JSDOM(`<!DOCTYPE html><p>Hello world</p>`);
console.log(dom.window.document.querySelector("p").textContent);

// Extract window and document for easier access
const { window } = new JSDOM(`<html><body><div id="content">Original content</div></body></html>`);
const { document } = window;

// Manipulate the DOM
const contentDiv = document.getElementById("content");
contentDiv.textContent = "Modified content";
const newElement = document.createElement("span");
newElement.textContent = " - Added element";
contentDiv.appendChild(newElement);

console.log(document.body.innerHTML);

v28.0.0

jsdom 28.0.0 overhauls resource loading customization with a new API and fixes numerous bugs in XMLHttpRequest, WebSocket, and iframe handling.

  • Overhauled resource loading customization. See the new README for details on the new API.
  • Added MIME type sniffing to iframe and frame loads.
  • Fixed XMLHttpRequest fetches and WebSocket upgrade requests to be interceptable by the new customizable resource loading.
  • Fixed the referrer of a document to be set correctly when redirects are involved; it is now the initiating page, not the last hop in the redirect chain.
v27.4.0

This release adds TextEncoder/TextDecoder support, significantly improves HTML and XML byte decoding accuracy, and fixes a memory leak with Range objects.

  • Added TextEncoder and TextDecoder.
  • Improved decoding of HTML bytes by using the new @exodus/bytes package; it is now much more correct.
  • Improved decoding of XML bytes to use UTF-8 more often, instead of sniffing for meta charset or using the parent frame's encoding.
  • Fixed a memory leak when Ranges were used and then the elements referred to by those ranges were removed.
v27.3.0

This release improves CSS parsing capabilities and CSSOM object APIs through dependency updates.

  • Improved CSS parsing and CSSOM object APIs via updates to @acemir/cssom.


[ EXPLORE MORE ]

Related Repositories

Discover similar tools and frameworks used by developers