
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
dom-node-export
Advanced tools
A TypeScript library for exporting any DOM element, including styles, images, and web fonts, into a standalone XHTML document as a data URL.
Export any DOM node, including styles, images, and web fonts, into a standalone XHTML document as a data URL.
dom-node-export is a modern TypeScript library that allows you to export any DOM element from your web application or site as a fully self-contained XHTML document. All styles, images, and web fonts are preserved, so the exported node looks exactly as it does on your page.
Unlike popular "Save as image" tools that simply capture a static screenshot, dom-node-export gives you much more: it exports a live, interactive copy of any part of your web page. The result is not just a picture, but a real, editable mini-page that you can open in the browser, inspect, modify, make your own screenshots, or even study the code structure and styles in detail. This makes sharing, archiving, or analyzing UI fragments far more powerful and flexible.
Use it to:
npm install dom-node-export
import { exportNode } from 'dom-node-export';
const node = document.getElementById('export-me');
const dataUrl = await exportNode(node);
console.log(dataUrl); // data:application/xhtml+xml;base64,...
import { exportNode } from 'dom-node-export';
async function downloadNodeAsFile(node: HTMLElement) {
const dataUrl = await exportNode(node, {
docTitle: 'Exported Node',
docFaviconUrl: '/favicon.ico',
styles: {
body: { margin: '2rem', background: '#fafafa' },
},
});
const a = document.createElement('a');
a.href = dataUrl;
a.download = 'exported-node.xhtml';
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
}
// Usage
const node = document.querySelector('.exportable');
if (node) downloadNodeAsFile(node as HTMLElement);
import { exportNode, StyleMode } from 'dom-node-export';
const node = document.querySelector('.doc');
const dataUrl = await exportNode(node, {
styleMode: StyleMode.Computed,
filter: (el) => !el.classList.contains('hidden'),
styles: {
node: { boxShadow: '0 2px 8px rgba(0,0,0,0.1)' },
selectors: {
html: {
fontSize: '18px',
},
body: {
padding: '2rem',
background: '#fff',
},
},
},
docTitle: 'My Exported Component',
docFaviconUrl: 'data:image/png;base64,...',
});
exportNode<T extends HTMLElement>(node: T, options?: ExportOptions): Promise<string>Exports a DOM node as a standalone XHTML document (data URL).
node - The DOM element to export.options - (Optional) Export options:| Option | Type | Description |
|---|---|---|
styleMode | StyleMode | 'Computed' (default) or 'Declared' for style application |
styles | StyleMap | Custom styles for html, body, or the exported node |
docTitle | string | Document title |
docFaviconUrl | string | Favicon URL or data URI |
filter | (node: HTMLElement) => boolean | Filter function to include/exclude nodes |
cacheBust | boolean | If true, appends a cache-busting query param to external resources (default: false) |
imagePlaceholder | string | Data URI or URL to use as a placeholder for failed image loads |
fetchInit | RequestInit | Custom fetch options for loading external resources |
Promise<string> - Data URL of the exported XHTML document.export enum StyleMode {
Computed = 'computed',
Declared = 'declared',
}
export interface ExportOptions {
docFaviconUrl?: string;
docTitle?: string;
styleMode?: StyleMode;
styles?: StyleMap;
filter?: (node: HTMLElement) => boolean;
cacheBust?: boolean;
includeQueryParams?: boolean;
imagePlaceholder?: string;
preferredFontFormat?: string;
fetchInit?: RequestInit;
}
export interface StyleMap {
node?: Partial<CSSStyleDeclaration>;
selectors?: Readonly<Record<string, Partial<CSSStyleDeclaration>>>;
}
filter option to exclude hidden or irrelevant nodes.MIT © Yegor Pelykh
Made with ❤️ and TypeScript.
FAQs
A TypeScript library for exporting any DOM element, including styles, images, and web fonts, into a standalone XHTML document as a data URL.
The npm package dom-node-export receives a total of 4 weekly downloads. As such, dom-node-export popularity was classified as not popular.
We found that dom-node-export demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.