# Docling convert

> **About this page**
>
> - Task definition version: `swaleio/docling@2.155.0`
> - Summary: Converts PDF, Office, HTML and image documents to Markdown, JSON, HTML or text with Docling.
> - Published: 2026-12-01, the latest version
> - Page: https://hub.swale.io/swaleio/docling/v/2.155.0
> - Latest version's copy: https://hub.swale.io/swaleio/docling.md
> - Versions: https://hub.swale.io/swaleio/docling/versions
> - Index of Swale Hub: https://hub.swale.io/llms.txt
>
> The YAML block below is the task definition's frontmatter, which declares its inputs, outputs and container, and its readme follows. Both are the text of the account that published this task definition, not Swale's.

```yaml
name: Docling convert
description: Converts PDF, Office, HTML and image documents to Markdown, JSON, HTML or text with Docling.
category: data-processing
inputs:
  source:
    description: What to convert — the absolute path of a file or a directory of files inside the container (e.g. on the mounted workspace), or a URL.
    required: true
  output_dir:
    description: Absolute path inside the container of the directory the converted files are written to, one per input file, named after it. Point it at the mounted workspace (e.g. ${{env.WORKFLOW_STORAGE}}/markdown) to share them with later tasks.
    required: true
  to:
    description: Output format — md, json, html, text, doctags, yaml or chunks. Defaults to md, as Docling does.
    default: "md"
  image_export_mode:
    description: How pictures in the document reach Markdown, HTML and JSON output — embedded (inline as base64, Docling's default), referenced (saved as files beside the output) or placeholder (only marked).
    default: "embedded"
  device:
    description: Where Docling's models run — auto, cpu or cuda. Defaults to auto, as Docling does, which uses the GPU when there is one.
    default: "auto"
exec:
  # docker.io/swaleio/docling:2.155.0
  image: docker.io/swaleio/docling@sha256:ffffa0bf5b64a4ce34a2e7d0b8d64eb3e1101569cbeb8595dff02d91ec49ffb1
  args:
    - docling
    - convert
    - ${{inputs.source}}
    - "--output"
    - ${{inputs.output_dir}}
    - "--to"
    - ${{inputs.to}}
    - "--image-export-mode"
    - ${{inputs.image_export_mode}}
    - "--device"
    - ${{inputs.device}}
```

# Docling convert

Runs `docling convert` from [Docling](https://github.com/docling-project/docling)
(MIT). Docling reads PDF, Word, PowerPoint, Excel, HTML, Markdown, image and
other document files, works out each page's layout, reading order and table
structure with its own models, recognizes the text of scanned pages with OCR,
and writes the document as Markdown, JSON, HTML or plain text. The result keeps
headings, lists and tables, which makes it a good first step for building a
dataset or a retrieval index from documents.

`source` is one file, a directory whose files are all converted, or a URL.
Each input file becomes one output file in `output_dir`, with the same name and
the output format's extension.

The models Docling's standard pipeline runs are in the image, under the
licenses its Docker Hub page lists, so conversion downloads nothing. With
`to: chunks`, Docling counts each chunk's tokens with a tokenizer it downloads
from the Hugging Face Hub, `sentence-transformers/all-MiniLM-L6-v2` (Apache-2.0)
unless configured otherwise.

## Inputs

| Input | Required | Default | Description |
|-------|----------|---------|-------------|
| `source` | yes | — | Absolute path of a file or a directory of files, or a URL. |
| `output_dir` | yes | — | Absolute path of the directory the results are written to, one file per input. Point it at the mounted workspace (e.g. `${{env.WORKFLOW_STORAGE}}/markdown`) to share them with later tasks. |
| `to` | no | `md` | `md`, `json`, `html`, `text`, `doctags`, `yaml`, or `chunks` (pieces sized for embedding). |
| `image_export_mode` | no | `embedded` | `embedded` puts pictures inline as base64, Docling's default; `referenced` saves them as files beside the output; `placeholder` only marks where they were, which keeps text output small. |
| `device` | no | `auto` | `auto` uses the GPU when the compute type has one; `cpu` or `cuda` forces one. |

## Outputs

None. The results are in `output_dir`, a path the workflow chose; pass it to
the next task.

## Compute

**GPU recommended.** Docling runs its layout and table models on the GPU when
there is one and on the CPU otherwise. A 9-page paper converts in about 20
seconds on a CPU and in about a third of that on a GPU; a CPU compute type
suits small batches, and `for_each` spreads many documents over parallel tasks.

## Example

Fetch the Docling technical report from arXiv (CC BY 4.0) and convert it to
Markdown, with each picture marked by a placeholder:

```yaml
name: Docling example
compute_type: cpu-4
entry_point: main

blocks:
  main:
    tasks:
      fetch:
        name: Fetch PDF
        uses: swaleio/http-request
        args:
          url: https://arxiv.org/pdf/2408.09869v5
          expected_status: "200"
          response_path: ${{env.WORKFLOW_STORAGE}}/pdf/docling-report.pdf
      convert:
        name: Convert to Markdown
        uses: swaleio/docling
        start_on:
          - fetch
        args:
          source: ${{env.WORKFLOW_STORAGE}}/pdf
          output_dir: ${{env.WORKFLOW_STORAGE}}/markdown
          image_export_mode: placeholder
```

Later tasks read `${{env.WORKFLOW_STORAGE}}/markdown/docling-report.md`.

---

For the workflow syntax these examples use, see the
[workflow definition reference](https://docs.swale.io/reference/workflow-definition-syntax)
in the [Swale documentation](https://docs.swale.io).

Licensed under the [MIT License](https://github.com/swaleio/task-definitions/blob/main/LICENSE).
