Legacy DOCX Import & Export

Editor

The original extension-import and extension-export packages for Tiptap provide reliable methods to import and export DOCX files.

These extensions, and associated endpoints remain available to anyone with a Tiptap account but are no longer actively developed.

They will be officially sunset later in 2025 and replaced by the new Tiptap Conversion extensions and services.

The following guide focuses on configuring the legacy extensions.

Import legacy extension

Legacy Import Extension Deprecation

The extension-import package will no longer be supported later 2025. Please plan to migrate to our newer solutions or alternative endpoints before then to ensure uninterrupted service.

// Start with importing the extension
import { Import } from '@tiptap-pro/extension-import'

const editor = new Editor({
  // ...
  extensions: [
    // ...
    Import.configure({
      // The Convert App-ID from the Convert settings page: https://cloud.tiptap.dev/convert-settings
      appId: 'your-app-id',

      // The JWT token you generated in the previous step
      token: 'your-jwt',

      // The URL to upload images to, if not provided, images will be stripped from the document
      imageUploadCallbackUrl: 'https://your-image-upload-url.com',

      // Enables the experimental DOCX import which should better preserve content styling
      experimentalDocxImport: true,
    }),
  ],
})

Import your first document

// The most simple way to import a file
// This will import the uploaded file, replace the editor content
// and focus the editor
editor.chain().focus().import({ file }).run()

Customize the import behavior

// You can also use the onImport callback to customize the import behavior
editor
  .chain()
  .import({
    file,
    onImport(context) {
      const { setEditorContent, content, error } = context

      // add error handling
      if (error) {
        showErrorToast({ message: error.message })
      }

      // You could also modify the content before inserting it
      content.doc.content.push({ type: 'paragraph', content: [{ type: 'text', text: 'Hello!' }] })

      // you can change the loading state of your application for example
      isLoading = false

      // make sure you call the setEditorContent function if you want to run
      // the default insertion behavior of the extension
      // setEditorContent()
      // but since we modified the content, we need to do the insertion manually
      editor.commands.setContent(content)
    },
  })
  .focus()
  .run()

Import options

NameTypeDefaultDescription
appIdstringundefinedThe convert app ID from the Convert settings page: https://cloud.tiptap.dev/convert-settings
tokenstringundefinedThe JWT token generated from your server via secret
imageUploadCallbackUrlstringundefinedThe URL to upload images to, if not provided, images will be stripped from the document, see more info
experimentalDocxImportboolean falseEnables the experimental DOCX import which should better preserve content styling (experimental, and this API may not be completely stable while in alpha), only applies to DOCX files uploaded

Commands

NameDescription
importImport a file into the editor

import

Arguments
NameTypeDefaultOptionsDescription
fileFileundefinedAny fileThe file to import
formatstringundefinedgfmIs used for special cases where the format is not clear, for example markdown gfm
onImportFunctionundefinedfn(context)A callback used to customize the import behavior. The context argument includes information about the content, errors and a setEditorContent function to modify the content

Supported formats

  • docx - Microsoft Word, Google Docs, OpenOffice, LibreOffice and others
  • odt - OpenDocument Text format used by OpenOffice, LibreOffice and others
  • rtf - Rich Text Format used by Microsoft Word, Google Docs and others
  • Commonmark markdown - Markdown format used by various editors and platforms
  • GFM markdown - GitHub Flavored Markdown used by GitHub

Caveats and limitations

  • Image upload - Images are assumed to be inline within the document so, your editor should be setup with Image.configure({ inline: true }) to display them correctly, otherwise they will be stripped from the document
  • Unsupported docx elements on import - Importing docx files currently does not support page breaks, page headers and footers, horizontal rules or text styles
  • Content added via suggestion mode - Content added via suggestion mode is not included in the imported prosemirror document
  • PDF import & export - Importing and exporting PDF files is not yet supported
  • Inline styles - Inline styles are currently not parsed and are not available in import & export

Export legacy extension

Legacy Export Extension Deprecation

The extension-export package will no longer be supported later 2025. We strongly recommend transitioning to our updated export extension, which offer improved customization and ongoing support.

// Start with importing the extension
import { Export } from '@tiptap-pro/extension-export'

const editor = new Editor({
  // ...
  extensions: [
    // ...
    Export.configure({
      // The Convert App-ID from the convert settings page: https://cloud.tiptap.dev/convert-settings
      appId: 'your-app-id',

      // The JWT token you generated in the previous step
      token: 'your-jwt',
    }),
  ],
})

Export a document

// Do a simple export to docx
// Supported formats: docx, odt, md and gfm
editor.chain().focus().export({ format: 'docx' }).run()

Customize the export behavior

// You can also use the onExport callback to customize the export behavior
editor.chain().export({
  format: 'docx',
  onExport(context) {
    const { blob, error, download, filename } = context

    // add error handling
    if (error) {
      showErrorToast({ message: error.message })
    }

    // you can change the loading state of your application for example
    isLoading = false

    // you could modify the filename or handle the blob differently here
    // but we will keep them as they are

    // you can trigger a download directly by calling the download method
    download()

    // keep in mind that the download method will only work in the browser
    // and if the blob and filename was changed before must be managed manually
  },
})

Export options

NameTypeDefaultDescription
appIdstringundefinedThe convert app ID from the Convert settings page: https://cloud.tiptap.dev/convert-settings
tokenstringundefinedThe JWT token generated from your server via secret

Commands

NameDescription
exportExport the editor content

export

Arguments
NameTypeDefaultOptionsDescription
formatstringundefineddocx,odt,md,gfmThe format you want to export to
contentJSONContentundefinedAny Tiptap JSONThe Tiptap JSON content you want to export
onExportFunctionundefinedfn(context)A callback used to customize the export behavior. The context argument includes information about the blob, filename, errors and a download function to download the document directly

Supported formats

  • docx - Microsoft Word, Google Docs, OpenOffice, LibreOffice and others
  • odt - OpenDocument Text format used by OpenOffice, LibreOffice and others
  • Commonmark markdown - Markdown format used by various editors and platforms
  • GFM markdown - GitHub Flavored Markdown used by GitHub

Caveats and limitations

  • Custom Node exports - Exporting custom nodes or marks is supported in the new Conversion extensions and endpoints.
  • Custom docx templates - Review our new Conversion extensions and endpoints to integrate docx templates.
  • PDF import & export - Exporting PDF files is not yet supported
  • Inline styles - Review our new Conversion extensions and endpoints to integrate inline styles.

Legacy REST API

Legacy /v1/ Conversion REST API Deprecation

The /v1/ Document Conversion REST API will not be supported later 2025. For continued updates and maintenance, migrate to newer API endpoints or check out our Postman Collection for the latest resources.

The legacy document conversion API supports DOCX, ODT, and Markdown conversion from and to Tiptap’s JSON format.

/import endpoint

The /import endpoint enables the conversion of docx, odt, or markdown files into Tiptap’s JSON format. Users can POST documents to this endpoint and use various parameters to customize how different document elements are handled during the conversion process.

  • Method: POST

Required headers

NameDescription
AuthorizationThe JWT token to authenticate the request. Example: Bearer your-jwt-token
X-App-IdThe Convert App-ID from the Collaboration settings page: https://cloud.tiptap.dev/convert-settings

Body

NameTypeDescription
fileFileThe file to convert
imageUploadCallbackUrlstringThe callback endpoint to upload images that were encountered within the uploaded document, see more info

Query parameters

Specify how source document elements are mapped to ProseMirror nodes or marks, and adjust the conversion to meet your specific styling and structural preferences.

NameDefaultDescription
paragraphparagraphDefines which prosemirror type is used for paragraph conversion
headingheadingDefines which prosemirror type is used for heading conversion
blockquoteblockquoteDefines which prosemirror type is used for blockquote conversion
codeblockcodeblockDefines which prosemirror type is used for codeblock conversion
bulletlistbulletlistDefines which prosemirror type is used for bulletList conversion
orderedlistorderedlistDefines which prosemirror type is used for orderedList conversion
listitemlistitemDefines which prosemirror type is used for listItem conversion
hardbreakhardbreakDefines which prosemirror type is used for hardbreak conversion
horizontalrulehorizontalruleDefines which prosemirror type is used for horizontalRule conversion
tabletableDefines which prosemirror type is used for table conversion
tablecelltablecellDefines which prosemirror type is used for tableCell conversion
tableheadertableheaderDefines which prosemirror type is used for tableHeader conversion
tablerowtablerowDefines which prosemirror type is used for tableRow conversion
boldboldDefines which prosemirror mark is used for bold conversion
italicitalicDefines which prosemirror mark is used for italic conversion
underlineunderlineDefines which prosemirror mark is used for underline conversion
strikethroughstrikeDefines which prosemirror mark is used for strikethrough conversion
linklinkDefines which prosemirror mark is used for link conversion
codecodeDefines which prosemirror mark is used for code conversion
imageimageDefines which prosemirror mark is used for image conversion

/import-docx endpoint (experimental)

The /import-docx endpoint enables the conversion of docx files into Tiptap's JSON format and allows for more docx-specific functions than the /import endpoint. Users can POST documents to this endpoint and use various parameters to customize how different document elements are handled during the conversion process.

  • Method: POST

Required headers

NameDescription
AuthorizationThe JWT token to authenticate the request. Example: Bearer your-jwt-token
X-App-IdThe Convert App-ID from the Collaboration settings page: https://cloud.tiptap.dev/convert-settings

Body

NameTypeDescription
fileFileThe file to convert
imageUploadCallbackUrlstringThe callback endpoint to upload images that were encountered within the uploaded document, see more info

Query parameters

Specify how source document elements are mapped to ProseMirror nodes or marks, and adjust the conversion to meet your specific styling and structural preferences.

NameDefaultDescription
paragraphparagraphDefines which prosemirror type is used for paragraph conversion
headingheadingDefines which prosemirror type is used for heading conversion
blockquoteblockquoteDefines which prosemirror type is used for blockquote conversion
codeblockcodeblockDefines which prosemirror type is used for codeblock conversion
bulletlistbulletlistDefines which prosemirror type is used for bulletList conversion
orderedlistorderedlistDefines which prosemirror type is used for orderedList conversion
listitemlistitemDefines which prosemirror type is used for listItem conversion
hardbreakhardbreakDefines which prosemirror type is used for hardbreak conversion
horizontalrulehorizontalruleDefines which prosemirror type is used for horizontalRule conversion
tabletableDefines which prosemirror type is used for table conversion
tablecelltablecellDefines which prosemirror type is used for tableCell conversion
tableheadertableheaderDefines which prosemirror type is used for tableHeader conversion
tablerowtablerowDefines which prosemirror type is used for tableRow conversion
boldboldDefines which prosemirror mark is used for bold conversion
italicitalicDefines which prosemirror mark is used for italic conversion
underlineunderlineDefines which prosemirror mark is used for underline conversion
strikethroughstrikeDefines which prosemirror mark is used for strikethrough conversion
linklinkDefines which prosemirror mark is used for link conversion
codecodeDefines which prosemirror mark is used for code conversion
imageimageDefines which prosemirror mark is used for image conversion

/export endpoint

The /export endpoint converts Tiptap documents back into formats like docx, odt, or markdown.

  • Method: POST

Convert a Tiptap document to a different format.

Required headers

NameDescription
AuthorizationThe JWT token to authenticate the request. Example: Bearer your-jwt-token
X-App-IdThe Convert App-ID from the Collaboration settings page: https://cloud.tiptap.dev/convert-settings

Body

NameTypeDescription
contentObjectThe Tiptap document
formatstringThe format to convert to, can be docx, odt or markdown

Query parameters

NameDefaultDescription
gfm0Use Github Flavored Markdown for markdown export
paragraphparagraphDefines which prosemirror type is used for paragraph conversion
headingheadingDefines which prosemirror type is used for heading conversion
blockquoteblockquoteDefines which prosemirror type is used for blockquote conversion
codeblockcodeblockDefines which prosemirror type is used for codeblock conversion
bulletlistbulletlistDefines which prosemirror type is used for bulletList conversion
orderedlistorderedlistDefines which prosemirror type is used for orderedList conversion
listitemlistitemDefines which prosemirror type is used for listItem conversion
hardbreakhardbreakDefines which prosemirror type is used for hardbreak conversion
horizontalrulehorizontalruleDefines which prosemirror type is used for horizontalRule conversion
tabletableDefines which prosemirror type is used for table conversion
tablecelltablecellDefines which prosemirror type is used for tableCell conversion
tableheadertableheaderDefines which prosemirror type is used for tableHeader conversion
tablerowtablerowDefines which prosemirror type is used for tableRow conversion
boldboldDefines which prosemirror mark is used for bold conversion
italicitalicDefines which prosemirror mark is used for italic conversion
underlineunderlineDefines which prosemirror mark is used for underline conversion
strikethroughstrikeDefines which prosemirror mark is used for strikethrough conversion
linklinkDefines which prosemirror mark is used for link conversion
codecodeDefines which prosemirror mark is used for code conversion