> ## Documentation Index
> Fetch the complete documentation index at: https://docs.superdoc.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Import and export

SuperDoc treats DOCX as the real document, not an export target. Load a Word file, edit it in the browser, and export a Word file again. Tracked changes, comments, and complex tables all stay intact. HTML and Markdown are useful for AI-generated content; DOCX is the full-fidelity path.

For the full reference, see [Editor > SuperDoc > Import/Export](https://docs.superdoc.dev/editor/superdoc/import-export.md).

## Loading a document

Pass anything that looks like a document to the `document` option:

```javascript theme={null}
new SuperDoc({
  selector: '#editor',
  document: docxFile, // File, Blob, URL string, or config object
});
```

For HTML, Markdown, or JSON content, pair the alternate input with a base DOCX (used for styles):

```javascript theme={null}
new SuperDoc({
  selector: '#editor',
  document: blankDocx,
  html: '<h1>Title</h1><p>Content</p>',
  // markdown: '# Title\n\nContent'
  // jsonOverride: documentSchema
});
```

## Exporting

Default `superdoc.export()` triggers a browser download. To upload to your backend instead, ask for the raw `Blob`:

```javascript theme={null}
// Download
await superdoc.export();

// Upload: get the Blob, send it yourself
const blob = await superdoc.export({ triggerDownload: false });
await fetch('/api/save', { method: 'POST', body: blob });
```

For HTML, JSON, or Markdown output, read directly from the active editor:

```javascript theme={null}
const html = superdoc.activeEditor.getHTML();
const json = superdoc.activeEditor.getJSON();
const markdown = await superdoc.activeEditor.getMarkdown();
```

## Format tradeoffs

| Format | Round-trip fidelity | Use it for |
| - | - | - |
| **DOCX** | Full | Real Word documents: open in Word with nothing lost |
| **JSON** | Full | Programmatic control, AI/agent input/output |
| **HTML** | Structure only (no CSS) | Web content, AI-generated HTML |
| **Markdown** | Structure only | Documentation, simple AI input |

DOCX preserves tracked changes, comments, complex tables, and section breaks. HTML and Markdown are structure-first: they don't preserve Word-specific formatting.

## What should I store in my backend?

Store the **DOCX blob** if you want full fidelity (recommended). Store JSON if you want programmatic search/diff and don't need round-tripping with Word users. Don't store HTML or Markdown unless you accept losing fidelity.

## Common pitfalls

* **Duplicate downloads.** `superdoc.export()` triggers a browser download by default. If you want to upload to a backend, pass `{ triggerDownload: false }`: otherwise you get the file twice.
* **HTML import without a base DOCX.** The `html` and `markdown` options need a `document` (a base `.docx`) for styles. Without one, headings and lists fall back to defaults.
* **HTML round-trips lose styling.** Importing HTML, exporting DOCX, and then importing the resulting HTML back will not produce the original Word styling. For round-tripping, use DOCX or JSON.

## Where to next

* [Editor > SuperDoc > Import/Export](https://docs.superdoc.dev/editor/superdoc/import-export.md): full API reference (every option, every export flag)
* [Editor > SuperDoc > Configuration](https://docs.superdoc.dev/editor/superdoc/configuration.md): `document`, `html`, `markdown`, `jsonOverride` config
* [Editor > SuperDoc > Methods](https://docs.superdoc.dev/editor/superdoc/methods.md): `superdoc.export()`, `getHTML()`, `getJSON()`, `getMarkdown()`
* [Document Engine](https://docs.superdoc.dev/document-engine/overview.md): server-side import/export via SDKs and CLI
* [Editor > Collaboration > Storage](https://docs.superdoc.dev/editor/collaboration/storage.md): persistence patterns for collaborative docs


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.