# @slate-serializers/dom

> Serialize Slate JSON objects to the DOM. Can be used with `htmlparser2` and associated utilities to modify the DOM and generate HTML. Used by other serializers in this monorepo.

Latest version **2.8.5** (published 2026-10-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install @slate-serializers/dom
pnpm add @slate-serializers/dom
yarn add @slate-serializers/dom
bun add @slate-serializers/dom
```

## Health

**Score 65/100 (B)** — status: active.

Positive: has types; no vulnerabilities; has provenance; recently updated; high maintenance score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 2.8.5 |
| Published | 2026-10-24 |
| First published | 2023-07-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 8 |
| Unpacked size | 48.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 94 |
| Maintainers | thompsonsj |
| Keywords | slate, slate-js, serializer, rich-text, dom, domhandler, htmlparser2, slate-to-dom |

## Links

- npm: https://www.npmjs.com/package/@slate-serializers/dom
- Repository: https://github.com/thompsonsj/slate-serializers
- Homepage: https://github.com/thompsonsj/slate-serializers/tree/main/packages/dom#readme
- Issues: https://github.com/thompsonsj/slate-serializers/issues
- npm.io page: https://npm.io/package/@slate-serializers/dom

## Dependencies (8)

- [slate](https://npm.io/package/slate.md) ^0.126.2
- [tslib](https://npm.io/package/tslib.md) 2.8.1
- [domutils](https://npm.io/package/domutils.md) ^4.0.0
- [css-select](https://npm.io/package/css-select.md) 7.0.0
- [domhandler](https://npm.io/package/domhandler.md) ^6.0.0
- [htmlparser2](https://npm.io/package/htmlparser2.md) 12.0.0
- [html-entities](https://npm.io/package/html-entities.md) ^2.6.0
- [dom-serializer](https://npm.io/package/dom-serializer.md) ^3.1.1

## 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

- 2.8.5 (latest) — 2026-10-24
- 2.8.4 — 2026-10-23
- 2.8.3 — 2026-10-19
- 2.8.2 — 2026-10-10
- 2.8.1 — 2026-10-09
- 2.8.0 — 2026-10-02
- 2.7.0 — 2026-09-28
- 2.6.0 — 2026-09-15
- 2.5.5 — 2026-07-26
- 2.5.4 — 2026-07-20
- 2.5.3 — 2026-04-20
- 2.5.2 — 2026-04-20
- 2.5.1 — 2026-04-18
- 2.5.0 — 2026-04-18
- 2.4.0 — 2026-04-18
- … 28 more at https://npm.io/package/@slate-serializers/dom/versions

## README

# @slate-serializers/dom

Convert [Slate](https://www.npmjs.com/package/slate) JSON to a [`domhandler`](https://github.com/fb55/domhandler) document tree (the same DOM model used by [`htmlparser2`](https://github.com/fb55/htmlparser2) / [`html-entities`](https://github.com/mdevils/html-entities)).

It is used by [`@slate-serializers/html`](https://www.npmjs.com/package/@slate-serializers/html) (`slateToHtml`) before serializing to an HTML string. Use **`slateToDom` directly** when you want to inspect or manipulate the tree (e.g. with [`domutils`](https://github.com/fb55/domutils)) before calling `dom-serializer` yourself.

**Docs:** [all packages](https://github.com/thompsonsj/slate-serializers/blob/main/README.md) · [demo](https://thompsonsj.github.io/slate-serializers-demo) — [slateToDom](https://thompsonsj.github.io/slate-serializers-demo/slate-to-dom/docs)

## Install

```bash
npm install @slate-serializers/dom
```

## Usage

```ts
import { slateToDomConfig, slateToDom } from '@slate-serializers/dom'

const slate = [
  {
    type: 'h1',
    children: [{ text: 'Heading 1' }],
  },
]

const dom = slateToDom(slate, slateToDomConfig)
```

## Configuration

- **`SlateToDomConfig`** — `markMap`, `elementMap`, `elementTransforms`, `markTransforms`, `elementAttributeTransform`, and formatting options. See [slateToDom configuration](https://github.com/thompsonsj/slate-serializers/blob/main/docs/config/slateToDom.md) in the repo and the [interactive docs](https://thompsonsj.github.io/slate-serializers-demo/slate-to-dom/docs).

### DOM helpers from this package

`Element` and `Text` are **re-exported** from `domhandler` so you can use **`new Element(...)`** without adding `domhandler` only for the constructor:

```ts
import { Element, type SlateToDomConfig } from '@slate-serializers/dom'
```

`ChildNode` is available as **`import type { ChildNode }`** only.

## Engineering

See [Engineering decisions](https://github.com/thompsonsj/slate-serializers/blob/main/docs/engineering.md).

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