---
title: "Export custom nodes to .doc"
description: "Learn how to export custom nodes to DOC (legacy Word) files using the Export DOC extension."
canonical_url: "https://tiptap.dev/docs/conversion/export/doc/custom-nodes"
---

# Export custom nodes to .doc

Learn how to export custom nodes to DOC (legacy Word) files using the Export DOC extension.

- **1. Activate trial or subscribe**

  Start a [free trial](https://cloud.tiptap.dev/v2?trial=true) or [subscribe to the Start plan](https://cloud.tiptap.dev/v2/billing) in your account.
- **2. Install from private registry**

  To install this frontend extensions, authenticate to Tiptap's private npm registry by following the [setup guide](https://tiptap.dev/docs/guides/pro-extensions.md).

The `@tiptap-pro/extension-export-doc` extension supports custom node conversion, allowing you to define how custom nodes in your Tiptap schema should be rendered in DOC exports.

> **Requires Export DOCX extension:**
>
> Custom node conversion for DOC export requires the `@tiptap-pro/extension-export-docx` extension to be installed and configured in your editor. The DOC export uses DOCX generation under the hood before converting to DOC. Without it, the `customNodes` option will have no effect.

## Export custom nodes to .doc

Pass your custom node definitions via the `customNodes` option when configuring `ExportDoc`:

```ts
import { ExportDoc } from '@tiptap-pro/extension-export-doc'
import { ExportDocx } from '@tiptap-pro/extension-export-docx'

const editor = new Editor({
  extensions: [
    ExportDocx,
    ExportDoc.configure({
      token: 'YOUR_TOKEN',
      appId: 'YOUR_APP_ID',
      customNodes: [
        {
          type: 'hintbox',
          render: node => {
            // Define how your custom node renders in the document
          },
        },
      ],
      onCompleteExport(result) {
        // Handle the exported DOC
      },
    }),
  ],
})
```

### Define the custom node render function

And we will define how the `Hintbox` custom node should be rendered in the exported document:

```ts
import { ExportDoc } from '@tiptap-pro/extension-export-doc'
import {
  convertTextNode,
  Docx,
  ExportDocx,
  lineHeightToDocx,
  pixelsToHalfPoints,
  pointsToTwips,
} from '@tiptap-pro/extension-export-docx'

const editor = new Editor({
  extensions: [
    // Other extensions ...
    ExportDocx,
    ExportDoc.configure({
      token: 'YOUR_TOKEN',
      appId: 'YOUR_APP_ID',
      onCompleteExport: result => {
        const url = URL.createObjectURL(result)
        const a = document.createElement('a')
        a.href = url
        a.download = 'export.doc'
        a.click()
        URL.revokeObjectURL(url)
      },
      customNodes: [
        {
          type: 'hintbox',
          render: node => {
            return new Docx.Paragraph({
              children: node.content.map(content => convertTextNode(content)),
              style: 'Hintbox',
            })
            },
        },
      ],
      styleOverrides: {
        paragraphStyles: [
          {
            id: 'Hintbox',
            name: 'Hintbox',
            basedOn: 'Normal',
            next: 'Normal',
            quickFormat: false,
            run: {
              font: 'Aptos Light',
              size: pixelsToHalfPoints(16),
            },
            paragraph: {
              spacing: {
                before: pointsToTwips(12),
                after: pointsToTwips(12),
                line: lineHeightToDocx(1),
              },
              border: {
                top: { style: Docx.BorderStyle.SINGLE, size: 1, color: 'b8d8ff', space: 5 },
                bottom: { style: Docx.BorderStyle.SINGLE, size: 1, color: 'b8d8ff', space: 5 },
                right: { style: Docx.BorderStyle.SINGLE, size: 1, color: 'b8d8ff', space: 5 },
                left: { style: Docx.BorderStyle.SINGLE, size: 1, color: 'b8d8ff', space: 5 },
              },
              shading: {
                type: Docx.ShadingType.SOLID,
                color: 'e6f3ff',
              },
            },
          },
        ],
      },
    }),
    // Other extensions ...
  ],
})
```

You can construct any supported DOCX elements in the `render` function using the `Docx` library classes (`Paragraph`, `TextRun`, `Table`, etc.) that are provided via the `Docx` import from the `@tiptap-pro/extension-export-docx` package.
