# rehype-extract-meta

> Rehype plugin to extract meta data from an HTML document

Latest version **4.1.0** (published 2026-04-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install rehype-extract-meta
pnpm add rehype-extract-meta
yarn add rehype-extract-meta
bun add rehype-extract-meta
```

## Health

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

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

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 4.1.0 |
| Published | 2026-04-11 |
| First published | 2021-09-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 12.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 7 |
| Author | Goran Spasojevic |
| Maintainers | gorango |
| Keywords | unist, rehype, hast, html, nlp, extract, meta |

## Links

- npm: https://www.npmjs.com/package/rehype-extract-meta
- Repository: https://github.com/gorango/rehype-extract-meta
- Homepage: https://github.com/gorango/rehype-extract-meta#readme
- Issues: https://github.com/gorango/rehype-extract-meta/issues
- npm.io page: https://npm.io/package/rehype-extract-meta

## Dependencies (2)

- [hast-util-select](https://npm.io/package/hast-util-select.md) ^6.0.4
- [hast-util-to-string](https://npm.io/package/hast-util-to-string.md) ^3.0.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

- 4.1.0 (latest) — 2026-04-11
- 4.0.1 — 2025-06-11
- 4.0.0 — 2024-04-06
- 3.1.0 — 2024-03-20
- 3.0.0 — 2024-03-11
- 2.1.0 — 2023-06-28
- 2.0.5 — 2023-02-21
- 2.0.4 — 2022-11-07
- 2.0.3 — 2022-10-19
- 2.0.2 — 2022-09-02
- 2.0.1 — 2022-09-02
- 2.0.0 — 2022-07-13
- 1.0.1 — 2021-09-23
- 1.0.0 — 2021-09-22

## README

# rehype-extract-meta

[![Build][build-badge]][build]
[![Coverage][coverage-badge]][coverage]
[![Types][types-badge]][types]
[![Size][size-badge]][size]

[Rehype][rehype] plugin to extract meta data from an HTML document.

## Install

```
npm install rehype-extract-meta
```

## Use

```js
import { unified } from 'unified'
import rehypeParse from 'rehype-parse'
import rehypeStringify from 'rehype-stringify'
import rehypeExtractMeta from 'rehype-extract-meta'

const processor = unified()
  .use(rehypeParse)
  .use(rehypeExtractMeta)
  .use(rehypeStringify)

const htmlString = `<html>...</html>`
const vfile = processor.processSync(htmlString)
console.log(vfile.data.meta)
```

Running the above code with a valid `htmlString` will return a [VFile][vfile]
containing the extracted contents in its `data.meta` property, conforming to
the type [`Meta`](#meta).

## API

This package exports a single plugin function.

### `unified().use(rehypeExtractMeta)`

Extract meta data from HTML.

###### Returns

Transform ([`Transformer`][unified-transformer]).

### `Meta`

Data property (TypeScript type).

###### Fields

- `lang` (`string`) - Language string
- `date` (`string`) - Document date
- `title` (`string`) - Document title
- `description` (`string`) - Document description
- `keywords` (`string[]`) - Document keywords
- `author` (`string`) - Document author
- `publisher` (`string`) - Document publisher
- `copyright` (`string`) - Document copyright
- `pageUrl` (`string`) - Page URL
- `imageUrl` (`string`) - Image URL
- `feedUrl` (`string`) - Feed URL

## Types

This package is fully typed with [TypeScript](https://www.typescriptlang.org).
It exports the additional type [`Meta`](#meta).

[Rehype][rehype] plugin to extract meta data from an HTML document.

## License

[MIT][license] © [Goran Spasojevic][author]

<!-- Definitions -->

[build-badge]: https://github.com/gorango/rehype-extract-meta/workflows/main/badge.svg
[build]: https://github.com/gorango/rehype-extract-meta/actions
[coverage-badge]: https://img.shields.io/codecov/c/github/gorango/rehype-extract-meta.svg
[coverage]: https://codecov.io/github/gorango/rehype-extract-meta
[types-badge]: https://badgen.net/npm/types/rehype-extract-meta
[types]: https://www.npmjs.com/package/rehype-extract-meta
[size-badge]: https://badgen.net/packagephobia/publish/rehype-extract-meta
[size]: https://packagephobia.com/result?p=rehype-extract-meta
[rehype]: https://github.com/rehypejs/rehype
[unified-transformer]: https://github.com/unifiedjs/unified#transformer
[vfile]: https://github.com/vfile/vfile
[fixtures]: https://github.com/gorango/rehype-extract-meta/tree/main/fixtures
[bcp47Normalize]: https://github.com/wooorm/bcp-47-normalize
[license]: license
[author]: https://github.com/gorango

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