Export DOC from your editor

Available in Start planBetav0.3.0

Consider using DOCX instead

The DOC format is a legacy format from Microsoft Word 97-2003. For modern use, we recommend exporting to DOCX instead. Use DOC only when compatibility with older systems requires it.

Use Tiptap's @tiptap-pro/extension-export-doc to export your editor's content as a .doc file. This extension integrates DOC export functionality into your editor by sending the document to the Tiptap convert service for conversion.

You can also use the REST API instead if you'd prefer to handle the conversion on your end.

Install the DOC Export extension

The Conversion extensions are published in Tiptap's private npm registry. Integrate the extensions by following the private registry guide.

Once done you can install and import the Export DOC extension package.

npm i @tiptap-pro/extension-export-doc
import { ExportDoc } from '@tiptap-pro/extension-export-doc'

Configuring the extension

The ExportDoc extension can be configured with an ExportDocOptions (object) as an argument to the configure method with the following properties:

import { ExportDoc } from '@tiptap-pro/extension-export-doc'

const editor = new Editor({
  extensions: [
    // Other extensions ...
    ExportDoc.configure({
      endpoint: 'https://api.tiptap.dev/v2/convert',
      token: 'YOUR_TOKEN',
      appId: 'YOUR_APP_ID',
      styleOverrides: {},
      headers: {},
      footers: {},
      pageSize: { width: '21cm', height: '29.7cm' },
      pageMargins: { top: '1cm', bottom: '1cm', left: '1cm', right: '1cm' },
      onCompleteExport: (result) => {
        // Handle the exported Blob
      },
    }),
    // Other extensions ...
  ],
})
ParameterTypeDescriptionDefault
endpointstringThe Tiptap API endpoint for conversion'https://api.tiptap.dev/v2/convert'
tokenstringThe Tiptap JWT for authentication''
appIdstringThe Tiptap App ID for authentication''
styleOverridesRecord<string, string>Style overrides to apply to the exportundefined
headersHeaderConfigHeader configuration for the exported documentundefined
footersFooterConfigFooter configuration for the exported documentundefined
pageSizePageSizePage size configurationundefined
pageMarginsPageMarginsPage margins configurationundefined
onCompleteExport(result: Blob) => voidCallback that receives the exported file as a BlobThrows error if not provided

HeaderConfig

PropertyTypeDescription
evenAndOddHeadersbooleanWhether to use different headers for odd and even pages
differentFirstPagebooleanWhether to use a different header on the first page. When true, the first value is used on page one instead of default.
defaultstringThe standard default header on every page, or header on odd pages when evenAndOddHeaders is active. Accepts a plain text string or stringified Tiptap JSONContent for rich formatting.
firststringThe header on the first page. Only used when differentFirstPage is set to true. Accepts a plain text string or stringified Tiptap JSONContent for rich formatting.
evenstringThe header on even pages when the evenAndOddHeaders option is activated. Accepts a plain text string or stringified Tiptap JSONContent for rich formatting.

FooterConfig

PropertyTypeDescription
evenAndOddFootersbooleanWhether to use different footers for odd and even pages
differentFirstPagebooleanWhether to use a different footer on the first page. When true, the first value is used on page one instead of default.
defaultstringThe standard default footer on every page, or footer on odd pages when evenAndOddFooters is active. Accepts a plain text string or stringified Tiptap JSONContent for rich formatting.
firststringThe footer on the first page. Only used when differentFirstPage is set to true. Accepts a plain text string or stringified Tiptap JSONContent for rich formatting.
evenstringThe footer on even pages when the evenAndOddFooters option is activated. Accepts a plain text string or stringified Tiptap JSONContent for rich formatting.

PageSize

PropertyTypeDescriptionDefault
widthstringThe width of the page. Must be a positive number followed by a valid unit (cm, in, pt, pc, mm, px)."21cm"
heightstringThe height of the page. Must be a positive number followed by a valid unit (cm, in, pt, pc, mm, px)."29.7cm"

PageMargins

PropertyTypeDescriptionDefault
topstringThe top margin of the page. Can be negative. Must be a number followed by a valid unit (cm, in, pt, pc, mm, px)."1cm"
bottomstringThe bottom margin of the page. Can be negative. Must be a number followed by a valid unit (cm, in, pt, pc, mm, px)."1cm"
leftstringThe left margin of the page. Must be a positive number followed by a valid unit (cm, in, pt, pc, mm, px)."1cm"
rightstringThe right margin of the page. Must be a positive number followed by a valid unit (cm, in, pt, pc, mm, px)."1cm"

Export a DOC file

With the extension installed, you can export your editor's content to .doc using the exportDoc command.

/**
 * Export the current document as a DOC file via the Tiptap convert service.
 *
 * @param options - All extension-level options can be overridden per-invocation
 * @example editor.commands.exportDoc({ onCompleteExport: (result) => {} })
 */
exportDoc: (options?: ExportDocCommandOptions) => ReturnType

The ExportDocCommandOptions interface extends ExportDocOptions, so every configuration option can be overridden per-command invocation:

PropertyTypeDescription
endpointstringOverride the API endpoint for this specific export
tokenstringOverride the JWT token for this specific export
appIdstringOverride the App ID for this specific export
styleOverridesRecord<string, string>Override style overrides for this specific export
headersHeaderConfigOverride header configuration for this specific export
footersFooterConfigOverride footer configuration for this specific export
pageSizePageSizeOverride page size for this specific export
pageMarginsPageMarginsOverride page margins for this specific export
onCompleteExport(result: Blob) => voidOverride the callback for this specific export
import { ExportDoc } from '@tiptap-pro/extension-export-doc'

const editor = new Editor({
  extensions: [
    // Other extensions ...
    ExportDoc.configure({
      token: 'YOUR_TOKEN',
      appId: 'YOUR_APP_ID',
      onCompleteExport(result) {
        // Download the DOC file
        const url = URL.createObjectURL(result)
        const a = document.createElement('a')

        a.href = url
        a.download = 'document.doc'
        a.click()

        URL.revokeObjectURL(url)
      },
    }),
    // Other extensions ...
  ],
})

// Use the extension-level callback
editor.chain().exportDoc().run()

// Or override options for a specific export
editor.chain().exportDoc({
  pageSize: { width: '8.5in', height: '11in' },
  onCompleteExport(result) {
    // Custom handling for this specific export
    const url = URL.createObjectURL(result)
    window.open(url)
  },
}).run()

How it works

When you call exportDoc, the extension serializes the editor's document to JSON and sends it to the Tiptap convert service along with any configured options (style overrides, page layout, headers, footers). The service converts the document to DOC (legacy Word 97-2003 format) and returns it as a binary blob. The onCompleteExport callback receives this blob directly, which you can then download or process as needed. Errors are thrown as exceptions rather than passed through the callback.

Support & Limitations

FeatureSupport
Text content✓ Basic text, spacing, punctuation
Text formatting✓ Bold, italic, underline, strikethrough, alignment, line height
Block elements✓ Paragraphs, headings (1–6), blockquotes, ordered and unordered lists
Tables✓ Basic structure, header rows, colspan
Links✓ Hyperlinks
Media (Images)✓ Embedded images, size preserved
Styles✓ Font families*, Font colors, font sizes, background colors, line heights
Headers & Footers
Math
Sections & Page Breaks~ In development
Footnotes & Endnotes~ In development
Comments & Revisions
Table of Contents
Advanced Formatting✗ Columns, text direction, forms, macros, embedded scripts
Metadata
Text Boxes, Shapes, SmartArt
* Font families are supported as long as the target font is installed on the operative system when the exported file is opened.