---
title: "MarkdownManager API"
description: "Learn about the Markdown Manager API in Tiptap Editor. Get methods and options for handling Markdown content."
canonical_url: "https://tiptap.dev/docs/editor/markdown/api/markdown-manager"
---

# MarkdownManager API

Learn about the Markdown Manager API in Tiptap Editor. Get methods and options for handling Markdown content.

The `MarkdownManager` class is a stand-alone class that provides support for parsing and serializing Markdown content into Tiptap's document model.

## Methods

### Constructor

```typescript
new MarkdownManager(options?: {
  marked?: typeof marked,
  markedOptions?: MarkedOptions,
  indentation?: {
    style?: 'space' | 'tab',
    size?: number,
  },
})
```

### `MarkdownManager.hasMarked()`

Returns `true` or `false` depending on whether the `marked` library is available.

- **returns**: `boolean`

```js
const manager = new MarkdownManager()
manager.hasMarked() // true or false
```

### `MarkdownManager.registerExtension()`

Registers a Tiptap extension to be used for parsing and serializing Markdown content.

- **returns**: `void`
- **parameters**:
  - `extension`: A Tiptap extension to register.

```js
const manager = new MarkdownManager()
manager.registerExtension(MyCustomExtension)
```

### `MarkdownManager.parse()`

Parses a Markdown string into a Tiptap document.

- **returns**: `JSON` - The Tiptap document in JSON format.
- **parameters**:
  - `markdown`: A string containing the Markdown content to parse.

```js
const manager = new MarkdownManager()
const doc = manager.parse('# Hello World')
```

Markdown parsing preserves consecutive empty paragraphs by combining normal blank-line separation with `&nbsp;` markers when needed. For example, the first empty paragraph in a run is represented by blank lines, while later empty paragraphs in the same run are represented by `&nbsp;` so they survive a roundtrip back to JSON.

### `MarkdownManager.serialize()`

Serializes a Tiptap document or JSON content into a Markdown string.

- **returns**: `string` - The serialized Markdown string.
- **parameters**:
  - `content`: A Tiptap document or JSON content to serialize.

```js
const manager = new MarkdownManager()
const markdown = manager.serialize(doc)
```

### `MarkdownManager.renderNodeToMarkdown()`

Renders a single ProseMirror node to its Markdown representation.

- **returns**: `string` - The Markdown string for the given node.
- **parameters**:
  - **node**: A ProseMirror node to render.
  - **parentNode**: (optional) The parent ProseMirror node.
  - **index**: (optional) The index of the node within its parent.
  - **level**: (optional) The nesting level of the node.

```
const manager = new MarkdownManager()
const markdown = manager.renderNodeToMarkdown(node)
```

The renderer passes sibling context to extensions through `RenderContext.previousNode`, which is useful for decisions that depend on the previous node at the same level, such as preserving runs of empty paragraphs.

### `MarkdownManager.renderNodes()`

Renders an array of ProseMirror nodes to their combined Markdown representation.

- **returns**: `string` - The combined Markdown string for the given nodes.
- **parameters**:
  - **nodes**: An array of ProseMirror nodes to render.
  - **parentNode**: (optional) The parent ProseMirror node.
  - **separator**: (optional) A string to separate the rendered nodes. Defaults to `''`
  - **level**: (optional) The nesting level of the nodes. Defaults to `0`.
  - **level**: `number` - The nesting level of the nodes. Defaults to `0`.

## Properties

### `Markdown.instance`

The MarkedJS instance used for parsing Markdown content.

### `Markdown.indentCharacter`

The character used for indentation in lists. Defaults to a space (`' '`).

### `Markdown.indentString`

The string used for indentation in lists. Defaults to two spaces (`'  '`).
