Snapdom is a DOM capture engine that serializes live web page elements into images, videos, documents, and other formats. It converts any DOM subtree into PNG, JPG, WebP, SVG, PDF, or self-contained HTML, and can record animating elements as video files or animated GIFs using the browser's MediaRecorder API.
The library distinguishes itself through a plugin-based architecture that allows custom output format handlers and pipeline hooks to extend the capture process without re-cloning the source element. It manages separate caches for images, styles, and fonts with preloading and clearing methods to optimize memory and rendering speed, and resolves cross-origin assets through a configurable proxy to avoid canvas taint. Snapdom also supports visual regression testing by comparing captured subtrees against saved baselines, and can generate annotated screenshots with bounding boxes for use with large language models.
Additional capabilities include CSS effect rendering for transforms, shadows, clip-paths, blend modes, masks, and pseudo-elements, as well as font embedding to preserve original typography. The capture pipeline supports dimension and scale control, node filtering, form value capture, text find-and-replace, and timestamp overlays, with a reusable composable hook pattern for declarative use in component frameworks.