On this page
Overview
jsdom implements a subset of web standards, especially WHATWG DOM and HTML, in JavaScript for Node.js. It creates window and document objects that support DOM-oriented testing, server-side parsing, and validation of code that expects browser-like APIs.
Features and best fit
Based on official documentation; not hands-on tested · Content checked:
Key features
Create window and document objects from an HTML string
new JSDOM(html) constructs a DOM and exposes dom.window.document, allowing standard APIs such as querySelector to inspect and manipulate elements.
Sources: [2]
Configure URLs, resource loading, script execution, and visual hints
Options such as url, resources, runScripts, and pretendToBeVisual control relative-URL resolution, subresource loading, script execution, visibility state, and requestAnimationFrame support.
Sources: [2]
Best fit
Fits DOM-dependent unit and integration tests plus server-side HTML analysis
It is useful when code needs browser-like DOM APIs but running a full browser would add unnecessary cost or complexity.
Sources: [2]
Before adoption
It does not perform real layout or rendering
Even with pretendToBeVisual, jsdom does not implement actual layout or rendering. Pixel output, full navigation, and browser-specific behavior still require a real-browser tool such as Playwright.
Sources: [2]
Do not enable script execution for untrusted content
The README warns that the runScripts: 'dangerously' sandbox is not foolproof and code can potentially reach the Node.js environment. Keep script execution disabled for externally supplied HTML.
Sources: [2]
Official sources
- [1]jsdom/jsdom repository(2026-09-30)
- [2]jsdom README(2026-09-30)
- [3]jsdom 30.1.1 package metadata(2026-09-30)
- [4]jsdom v30.1.1 release(2026-09-30)
- [5]jsdom MIT license(2026-09-30)
Supplemental curator note
jsdom does not reproduce an entire browser; it implements enough web standards for testing and scraping in Node.js. Enabling runScripts: 'dangerously' on untrusted HTML can expose the Node.js environment, so script execution should remain disabled for external input.
Try it in 3 steps
- 1
Install jsdom 30.1.1
Pin the release in a project that satisfies the Node.js engine requirement.
npm install jsdom@30.1.1 - 2
Parse HTML with JSDOM
Create a minimal DOM without enabling script execution.
const { JSDOM } = require("jsdom"); const dom = new JSDOM("<p>Hello world</p>"); - 3
Query with DOM APIs
Verify that document and standard DOM APIs are available in Node.js.
console.log(dom.window.document.querySelector("p").textContent);
Growth
Growth trends · Last 30 days
21,695 Stars
Trend data is still being collected.
Built with
Categories and tags
Categories
GitHub data
GitHub dataView detailed GitHub data
GitHub Topics
- dom-apis
- html
- javascript
- jsdom
- nodejs
- Stars
- 21,695
- Forks
- 1,809
- Watchers
- 261
- Open issues
- 306
- Owner type
- Organization
- Primary language
- JavaScript
- License
- MIT
- Repository last updated
- Sep 22, 2026
Related information
Write a related articleShare a guide or use case for this OSS in Markdown. Articles are published after administrator approval.
Explore next
- Cheerio30,513 Stars
3 shared tag(s) · 1 shared category(s)
parse, query, and rewrite HTML or XML with a lightweight jQuery-style selector API
TypeScript - CodeceptJS4,242 Stars
2 shared tag(s) · 2 shared category(s) · Same language
unify Playwright and other E2E engines behind user-perspective
JavaScriptIsteps - fake-indexeddb695 Stars
2 shared tag(s) · 2 shared category(s) · Same language
recreate the IndexedDB API in memory for Node.js tests
JavaScript - Storybook91,178 Stars
2 shared tag(s) · 2 shared category(s)
capture UI states once and reuse them across docs, interaction tests, and agent tooling
TypeScript - Jest45,464 Stars
2 shared tag(s) · 2 shared category(s)
Combine assertions, mocks, watch mode, snapshots, coverage, and worker isolation in one JavaScript test runner
TypeScript - Markuplint619 Stars
2 shared tag(s) · 2 shared category(s)
lint markup against HTML and ARIA rules across HTML, React, Vue, Svelte, and other templates
TypeScript
Report incorrect information
Tell us if any listing information is incorrect or outdated.