# domify

> Turn a HTML string into DOM elements, cross-platform

Latest version **3.0.0** (published 2026-02-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install domify
pnpm add domify
yarn add domify
bun add domify
```

## Health

**Score 60/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2026-02-16 |
| First published | 2012-08-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=20 |
| Dependencies | 0 |
| Unpacked size | 4.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 262 |
| Maintainers | sindresorhus |
| Keywords | dom, html, client, browser, component, element, elements, string, document |

## Links

- npm: https://www.npmjs.com/package/domify
- Repository: https://github.com/sindresorhus/domify
- Homepage: https://github.com/sindresorhus/domify#readme
- Issues: https://github.com/sindresorhus/domify/issues
- Funding: https://github.com/sponsors/sindresorhus
- npm.io page: https://npm.io/package/domify

## Alternatives

- [@tsparticles/shape-image](https://npm.io/package/@tsparticles/shape-image.md) — 303.7K weekly downloads
- [@tsparticles/shape-line](https://npm.io/package/@tsparticles/shape-line.md) — 233.7K weekly downloads
- [stringify-attributes](https://npm.io/package/stringify-attributes.md) — 58.6K weekly downloads
- [mobile-drag-drop](https://npm.io/package/mobile-drag-drop.md) — 46.3K weekly downloads
- [@comunica/actor-rdf-parse-html](https://npm.io/package/@comunica/actor-rdf-parse-html.md) — 29.2K weekly downloads

## Recent versions

- 3.0.0 (latest) — 2026-02-16
- 2.0.0 — 2023-11-17
- 1.4.2 — 2023-11-17
- 1.4.1 — 2021-04-27
- 1.4.0 — 2015-08-26
- 1.3.3 — 2015-04-06
- 1.3.2 — 2015-03-10
- 1.3.1 — 2014-09-17
- 1.3.0 — 2014-07-14
- 1.2.2 — 2014-02-19
- 1.2.1 — 2014-01-31
- 1.1.1 — 2013-11-17
- 1.0.0 — 2013-06-13
- 0.2.0 — 2013-05-21
- 0.1.0 — 2012-10-25
- … 2 more at https://npm.io/package/domify/versions

## README

# domify

> Turn a HTML string into DOM elements, cross-platform

## Usage

Works out of the box in the browser:

```js
import domify from 'domify';

document.addEventListener('DOMContentLoaded', () => {
	const element = domify('<p>Hello <em>there</em></p>');
	document.body.appendChild(element);
});
```

You can also run it in Node.js and other non-browser environments by passing a custom implementation of `document`:

```js
import {JSDOM} from 'jsdom';

const jsdom = new JSDOM();

domify('<p>Hello <em>there</em></p>', jsdom.window.document);
```

**Note:** For browser-only use, prefer [`DOMParser.parseFromString()`](https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString).

---
_Source: https://npm.io/package/domify · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
