# @lexical/markdown

> This package contains Markdown helpers and functionality for Lexical.

Latest version **0.51.0** (published 2026-09-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install @lexical/markdown
pnpm add @lexical/markdown
yarn add @lexical/markdown
bun add @lexical/markdown
```

## Health

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

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score; popular repo.

Warnings: low downloads; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.51.0 |
| Published | 2026-09-17 |
| First published | 2022-04-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 9 |
| Unpacked size | 289 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 23878 |
| Maintainers | fantactuka, zurfyx, acywatson, ipavlov001, trueadm, etrepum |
| Keywords | lexical, editor, rich-text, markdown |

## Links

- npm: https://www.npmjs.com/package/@lexical/markdown
- Repository: https://github.com/facebook/lexical
- npm.io page: https://npm.io/package/@lexical/markdown

## Dependencies (9)

- [lexical](https://npm.io/package/lexical.md) 0.51.0
- [@lexical/link](https://npm.io/package/@lexical/link.md) 0.51.0
- [@lexical/list](https://npm.io/package/@lexical/list.md) 0.51.0
- [@lexical/text](https://npm.io/package/@lexical/text.md) 0.51.0
- [@lexical/utils](https://npm.io/package/@lexical/utils.md) 0.51.0
- [@lexical/internal](https://npm.io/package/@lexical/internal.md) 0.51.0
- [@lexical/code-core](https://npm.io/package/@lexical/code-core.md) 0.51.0
- [@lexical/rich-text](https://npm.io/package/@lexical/rich-text.md) 0.51.0
- [@lexical/selection](https://npm.io/package/@lexical/selection.md) 0.51.0

## Alternatives

- [ext-list](https://npm.io/package/ext-list.md) — 6.3M weekly downloads
- [@lexical/selection](https://npm.io/package/@lexical/selection.md) — 3.8M weekly downloads
- [@lexical/text](https://npm.io/package/@lexical/text.md) — 3.6M weekly downloads
- [@lexical/clipboard](https://npm.io/package/@lexical/clipboard.md) — 3.0M weekly downloads
- [@tiptap/extension-mention](https://npm.io/package/@tiptap/extension-mention.md) — 3.0M weekly downloads

## Recent versions

- 0.51.0 (latest) — 2026-09-17
- 0.51.1-nightly.20260924.0 (nightly) — 2026-09-24
- 0.45.1-dev.0 (dev) — 2026-05-30
- 0.6.1-next.0 (next) — 2022-11-04
- 0.51.1-nightly.20260923.0 — 2026-09-23
- 0.51.1-nightly.20260922.0 — 2026-09-22
- 0.51.1-nightly.20260921.0 — 2026-09-21
- 0.51.1-nightly.20260918.0 — 2026-09-18
- 0.50.1-nightly.20260917.0 — 2026-09-17
- 0.50.1-nightly.20260916.0 — 2026-09-16
- 0.50.1-nightly.20260915.0 — 2026-09-15
- 0.50.1-nightly.20260914.0 — 2026-09-14
- 0.50.1-nightly.20260911.0 — 2026-09-11
- 0.50.1-nightly.20260910.0 — 2026-09-10
- 0.50.1-nightly.20260909.0 — 2026-09-09
- … 672 more at https://npm.io/package/@lexical/markdown/versions

## README

# `@lexical/markdown`

[![See API Documentation](https://lexical.dev/img/see-api-documentation.svg)](https://lexical.dev/docs/api/modules/lexical_markdown)

This package contains markdown helpers for Lexical: import, export and shortcuts.

## Import and export
```js
import {
  $convertFromMarkdownString,
  $convertToMarkdownString,
  TRANSFORMERS,
} from '@lexical/markdown';

editor.update(() => {
  const markdown = $convertToMarkdownString(TRANSFORMERS);
  ...
});

editor.update(() => {
  $convertFromMarkdownString(markdown, TRANSFORMERS);
});
```

It can also be used for initializing editor's state from markdown string. Here's an example with react `<RichTextPlugin>`
```jsx
<LexicalComposer initialConfig={{
  editorState: () => $convertFromMarkdownString(markdown, TRANSFORMERS)
}}>
  <RichTextPlugin />
</LexicalComposer>
```

## Shortcuts
Can use `<MarkdownShortcutPlugin>` if using React
```jsx
import { TRANSFORMERS } from '@lexical/markdown';
import {MarkdownShortcutPlugin} from '@lexical/react/LexicalMarkdownShortcutPlugin';

<LexicalComposer>
  <MarkdownShortcutPlugin transformers={TRANSFORMERS} />
</LexicalComposer>
```

Or `registerMarkdownShortcuts` to register it manually:
```js
import {
  registerMarkdownShortcuts,
  TRANSFORMERS,
} from '@lexical/markdown';

const editor = createEditor(...);
registerMarkdownShortcuts(editor, TRANSFORMERS);
```

## Transformers
Markdown functionality relies on transformers configuration. It's an array of objects that define how certain text or nodes
are processed during import, export or while typing. `@lexical/markdown` package provides set of built-in transformers:
```js
// Element transformers
UNORDERED_LIST
CODE
HEADING
ORDERED_LIST
QUOTE

// Text format transformers
BOLD_ITALIC_STAR
BOLD_ITALIC_UNDERSCORE
BOLD_STAR
BOLD_UNDERSCORE
INLINE_CODE
ITALIC_STAR
ITALIC_UNDERSCORE
STRIKETHROUGH

// Text match transformers
LINK
```

And bundles of commonly used transformers:
- `TRANSFORMERS` - all built-in transformers
- `ELEMENT_TRANSFORMERS` - all built-in element transformers
- `MULTILINE_ELEMENT_TRANSFORMERS` - all built-in multiline element transformers
- `TEXT_FORMAT_TRANSFORMERS` - all built-in text format transformers
- `TEXT_MATCH_TRANSFORMERS` - all built-in text match transformers

Transformers are explicitly passed to markdown API allowing application-specific subset of markdown or custom transformers.

There're three types of transformers:

- **Element transformer** handles top level elements (lists, headings, quotes, tables or code blocks)
- **Text format transformer** applies text range formats defined in `TextFormatType` (bold, italic, underline, strikethrough, code, subscript and superscript)
- **Text match transformer** relies on matching leaf text node content

See `MarkdownTransformers.js` for transformer implementation examples

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