---
title: "Import documents"
canonical_url: "https://www.nutrient.io/guides/document-authoring/working-with-documents/import/"
md_url: "https://www.nutrient.io/guides/document-authoring/working-with-documents/import.md"
last_updated: "2026-07-08T00:00:00.000Z"
description: "Open DOCX, PDF, RTF, ODT, Markdown, plain text, and image files in Document Authoring with `DocAuthSystem.import()`."
---

# Import documents

Use [`DocAuthSystem.import()`](https://www.nutrient.io/api/document-authoring/types/docauthsystem/#import) to open files in Document Authoring. The method detects the format from the file content and optional file name, or you can pass the format explicitly. It returns a [`DocAuthDocument`](https://www.nutrient.io/api/document-authoring/types/docauthdocument/) that you can pass to an editor.

Before you start, make sure the Document Authoring library is installed and running in your app. If you haven’t set it up yet, refer to the [getting started](https://www.nutrient.io/sdk/document-authoring/getting-started.md) guide.

The examples omit error handling. Add it before you use this code in production.

## Supported formats

[`DocAuthSystem.import()`](https://www.nutrient.io/api/document-authoring/types/docauthsystem/#import) reads these formats:

- `docx`, `dotx`, `docm` — Microsoft Word.

- `rtf` — Rich Text Format.

- `odt` — OpenDocument Text.

- `markdown` — Markdown.

- `txt` — Plain text.

- `docjson` — Document Authoring’s native format.

- `png`, `jpeg`, `bmp`, `gif`, `webp` — Images.

DOCX support is an optional feature. As with any DOCX handling, import is best effort. After you import a DOCX file, save it as DocJSON and work from that saved document instead of reimporting the original file each time. For more information, refer to the [DocJSON](https://www.nutrient.io/guides/document-authoring/working-with-documents/docjson.md) guide.

## Import with automatic detection

Use automatic detection when a user selects a file and your app doesn’t know the format in advance. Pass the file to [`DocAuthSystem.import()`](https://www.nutrient.io/api/document-authoring/types/docauthsystem/#import), and include the file name to help Document Authoring distinguish similar file types:

```js

const fileInput = document.querySelector('input[type="file"]');

fileInput.addEventListener('change', async () => {
  const file = fileInput.files?.[0];
  if (!file) {
    return;
  }

  const importedDocument = await docAuthSystem.import(file, {
    fileName: file.name,
  });

  const editor = await docAuthSystem.createEditor(
    document.getElementById('editor'),
    { document: importedDocument },
  );
});

```

## Import with an explicit format

Pass a format explicitly when you already know it. This helps when the file comes from a source where the extension or MIME type isn’t reliable:

```js

const response = await fetch('/content/guide.md');

const importedDocument = await docAuthSystem.import(response, {
  format: 'markdown',
});

```

## Create a document from plain text

Use [`DocAuthSystem.createDocumentFromPlaintext()`](https://www.nutrient.io/api/document-authoring/types/docauthsystem/#createdocumentfromplaintext) when your source is plain text instead of a file:

```js

const text = 'First paragraph\n\nSecond paragraph.';

const textDocument = await docAuthSystem.createDocumentFromPlaintext(text, {
  pageSize: 'A4',
});

```

The method reads `\n` as a line break, `\n\n` as a paragraph break, and `\t` as spaces.

## Cancel a long import

Pass an `AbortSignal` to cancel an import that’s taking too long or is no longer needed:

```js

const controller = new AbortController();

const importedDocument = await docAuthSystem.import(
  fetch('/documents/template.odt'),
  { fileName: 'template.odt', abortSignal: controller.signal },
);

// `controller.abort()` cancels the import.

```

## Learn more

**[Export documents](https://www.nutrient.io/guides/document-authoring/working-with-documents/export.md)**\
Write the document to PDF, DOCX, Markdown, RTF, or ODT.

**[DocJSON](https://www.nutrient.io/guides/document-authoring/working-with-documents/docjson.md)**\
Load and save Document Authoring’s native format.

**[Programmatic editing](https://www.nutrient.io/guides/document-authoring/editing-content/programmatic-editing.md)**\
Read and change a document from code.
---

## Related pages

- [Import and export documents](/guides/document-authoring/working-with-documents/overview.md)
- [Export documents](/guides/document-authoring/working-with-documents/export.md)
- [First-class JSON support with DocJSON](/guides/document-authoring/working-with-documents/docjson.md)

