# Using MarkItDown in Python

> Use MarkItDown from Python: which convert method fits paths, bytes, uploads and URLs, what the result holds, and how to catch errors. Every example tested.

Source: https://markitdown.dev/python-api/ · Updated 2026-11-15·Upstream source ↗

One class, six conversion methods, one result object and a small family of exceptions. Every example on this page was executed on version 0.1.9, and the output shown is the output we captured.

> **Short answer**
>
> Import the class, build it once, convert a path, and read `.markdown`:
> 
> ```python
> from markitdown import MarkItDown
> 
> md = MarkItDown()
> result = md.convert("samples/report.docx")
> print(type(result).__name__)
> print(result.markdown[:160])
> ```
> 
> Output · markitdown 0.1.9 · Python 3.13.18 · 2026-11-15
> 
> ```
> DocumentConverterResult
> Pilot Report: Field Station Alpha
> 
> # 1. Summary
> 
> This report covers **three sites** during *spring 2026* <u>with underlined</u> ~~and struck text.~~
> 
> ## 1.1 Key
> ```
> 
> [captured result](https://markitdown.dev/evidence/snippets/api-convert-path/result.json)
> 
> Install the extras for your file types first ([extras](https://markitdown.dev/install/extras/)); the check script and the tables on [the missing-dependency page](https://markitdown.dev/errors/missing-dependency/) show what is installed.

Tested with markitdown 0.1.9 · Python 3.13 · markitdown\[all\] 0.1.9 · every snippet executed by scripts/run\_snippets.py (Linux lab); thread test and conversions also run in CI on three systems · 2026-11-15 · evidence: [api-surface.json](https://markitdown.dev/data/api-surface.json)

## Choose the right method for your input

| You have | Call | Note |
| --- | --- | --- |
| A local file path you control | `convert_local` (or `convert`) | `str` and `pathlib.Path` both work |
| Bytes, an open binary file, an upload | `convert_stream` with `StreamInfo` hints | the stream must be binary |
| A `requests` response you fetched | `convert_response` | its headers give the type and charset |
| A URL | `convert_uri` (alias `convert_url`) | fetched with the instance's session |
| A `file:` or `data:` URI | `convert_uri` |  |
| A string of HTML or text | wrap it as a bytes stream with a type hint | [below](#strings) |
| Not sure | `convert` | accepts all of the above |

> **Do not call convert on untrusted input:** convert accepts paths and URLs, so a user-supplied string can make your server read a local file or fetch an internal address. For untrusted input, convert only a stream you built yourself.

*Diagram: How convert routes its input. convert looks at the type of its argument: a string that starts with http or https, file or data goes to convert_uri; any other string or a Path goes to convert_local; a requests Response goes to convert_response; a binary file object goes to convert_stream. All four end in the same detection and converter selection.*

## Files on disk

`convert` takes a `str` or a `pathlib.Path`. A missing file raises `FileNotFoundError` and a folder raises `IsADirectoryError`:

```python
from pathlib import Path
from markitdown import MarkItDown

result = MarkItDown().convert(Path("samples") / "data.csv")
print(result.markdown)
```

Output · markitdown 0.1.9 · Python 3.13.18 · 2026-11-15

```
| station | rainfall_mm | notes |
| --- | --- | --- |
| Alpha | 412.5 | Battery, low |
| Bravo | 388.0 | OK \| stable |
| Charlie | 451.3 | café |
```

[captured result](https://markitdown.dev/evidence/snippets/api-convert-pathlib/result.json)

```python
from markitdown import MarkItDown

md = MarkItDown()
for path in ("samples/missing.docx", "samples"):
    try:
        md.convert(path)
    except Exception as e:
        print(f"{path!r}: {type(e).__name__}")
```

Output · markitdown 0.1.9 · Python 3.13.18 · 2026-11-15

```
'samples/missing.docx': FileNotFoundError
'samples': IsADirectoryError
```

[captured result](https://markitdown.dev/evidence/snippets/api-local-path-errors/result.json)

When the extension is wrong, tell MarkItDown with a hint (below). Write the result with an explicit encoding, because the default differs by system ([why](https://markitdown.dev/errors/unicodeencodeerror/)):

```python
from pathlib import Path
from markitdown import MarkItDown

text = MarkItDown().convert("samples/report.docx").markdown
Path("report.md").write_text(text, encoding="utf-8")   # explicit encoding: the same bytes on every system

data = Path("report.md").read_bytes()
print("bytes written:", len(data))
print("starts with a byte-order mark:", data[:3] == b"\xef\xbb\xbf")
print("keeps café, 東京 and the emoji:", all(s in data.decode("utf-8") for s in ("café", "東京", "\U0001F642")))
print("line endings: CRLF" if b"\r\n" in data else "line endings: LF")
```

Output · markitdown 0.1.9 · Python 3.13.18 · 2026-11-15

```
bytes written: 850
starts with a byte-order mark: False
keeps café, 東京 and the emoji: True
line endings: LF
```

[captured result](https://markitdown.dev/evidence/snippets/api-write-utf8/result.json)

## Bytes, uploads and in-memory data

### From bytes

```python
import io
from markitdown import MarkItDown

data = open("samples/report.docx", "rb").read()
result = MarkItDown().convert_stream(io.BytesIO(data))
print(result.markdown.splitlines()[0])
```

Output · markitdown 0.1.9 · Python 3.13.18 · 2026-11-15

```
Pilot Report: Field Station Alpha
```

[captured result](https://markitdown.dev/evidence/snippets/api-stream-bytesio/result.json)

Without hints MarkItDown detected the type from the bytes. When it cannot, say what you have; the fields of `StreamInfo` are:

```python
import dataclasses
from markitdown import StreamInfo

print([f.name for f in dataclasses.fields(StreamInfo)])
info = StreamInfo(extension=".pdf")
print(info.copy_and_update(mimetype="application/pdf", filename="a.pdf"))
print("frozen:", dataclasses.is_dataclass(info))
try:
    info.extension = ".docx"
except dataclasses.FrozenInstanceError as e:
    print("FrozenInstanceError:", e)
```

Output · markitdown 0.1.9 · Python 3.13.18 · 2026-11-15

```
['mimetype', 'extension', 'charset', 'filename', 'local_path', 'url']
StreamInfo(mimetype='application/pdf', extension='.pdf', charset=None, filename='a.pdf', local_path=None, url=None)
frozen: True
FrozenInstanceError: cannot assign to field 'extension'
```

[captured result](https://markitdown.dev/evidence/snippets/api-stream-info-fields/result.json)

A charset hint fixes a mis-detected text encoding:

```python
from markitdown import MarkItDown, StreamInfo

md = MarkItDown()
raw = open("samples/data-cp1252.csv", "rb")
guess = md.convert_stream(raw)
print("no hint:\n" + guess.markdown)
raw.seek(0)
fixed = md.convert_stream(raw, stream_info=StreamInfo(extension=".csv", charset="cp1252"))
print("charset=cp1252:\n" + fixed.markdown)
```

Output · markitdown 0.1.9 · Python 3.13.18 · 2026-11-15

```
no hint:
| station | notes |
| --- | --- |
| Alpha | cafķ dķjÓ vu |
| Bravo | na’ve Ć5 |
charset=cp1252:
| station | notes |
| --- | --- |
| Alpha | café déjà vu |
| Bravo | naïve €5 |
```

[captured result](https://markitdown.dev/evidence/snippets/api-stream-info-charset/result.json)

### From a web upload

Read the uploaded file into a binary buffer (`io.BytesIO`), pass the original file name and content type as hints, set a size limit before reading, and call `convert_stream`. A complete service is a separate recipe ([web service](https://markitdown.dev/recipes/api-server/)).

### Text-mode streams fail

A file opened in text mode is rejected with a `TypeError`: open it with `"rb"`.

```python
from markitdown import MarkItDown

with open("samples/data.csv", "r", encoding="utf-8") as f:   # text mode, not "rb"
    try:
        MarkItDown().convert(f)
    except TypeError as e:
        print("TypeError:", e)
```

Output · markitdown 0.1.9 · Python 3.13.18 · 2026-11-15

```
TypeError: Invalid source type: <class '_io.TextIOWrapper'>. Expected str, requests.Response, BinaryIO.
```

[captured result](https://markitdown.dev/evidence/snippets/api-text-stream-error/result.json)

A stream that cannot seek is buffered in memory first:

```python
import io
from markitdown import MarkItDown

class OneWay(io.RawIOBase):
    """A binary stream that reads forward only, like a pipe or a socket."""
    def __init__(self, data): self._b = io.BytesIO(data)
    def readable(self): return True
    def seekable(self): return False
    def readinto(self, buf): return self._b.readinto(buf)

stream = OneWay(open("samples/report.docx", "rb").read())
print("seekable:", stream.seekable())
result = MarkItDown().convert_stream(stream)
print(result.markdown.splitlines()[0])
```

Output · markitdown 0.1.9 · Python 3.13.18 · 2026-11-15

```
seekable: False
Pilot Report: Field Station Alpha
```

[captured result](https://markitdown.dev/evidence/snippets/api-stream-nonseekable/result.json)

### Converting a string

```python
import io
from markitdown import MarkItDown, StreamInfo

md = MarkItDown()
html = "<h1>Notes</h1><p>Hello <b>world</b> and <a href='https://example.org'>a link</a>.</p><ul><li>one</li><li>two</li></ul>"

# a string is not a path: wrap it as bytes and say what it is
result = md.convert_stream(io.BytesIO(html.encode("utf-8")), stream_info=StreamInfo(extension=".html", charset="utf-8"))
print(result.markdown)

# plain text passes through unchanged
text = md.convert_stream(io.BytesIO("just some text\nsecond line".encode()), stream_info=StreamInfo(extension=".txt"))
print(repr(text.markdown))
```

Output · markitdown 0.1.9 · Python 3.13.18 · 2026-11-15

```
# Notes

Hello **world** and [a link](https://example.org).

* one
* two
'just some text\nsecond line'
```

[captured result](https://markitdown.dev/evidence/snippets/api-convert-string/result.json)

## URLs

`convert` fetches `http(s)` URLs with the instance's `requests` session. The default headers ask for Markdown first:

```python
from markitdown import MarkItDown

result = MarkItDown().convert("http://127.0.0.1:8765/echo-headers")
print(result.markdown)
```

Output · markitdown 0.1.9 · Python 3.13.18 · 2026-11-15

```
{"Host": "127.0.0.1:8765", "User-Agent": "python-requests/2.34.2", "Accept-Encoding": "gzip, deflate", "Accept": "text/markdown, text/html;q=0.9, text/plain;q=0.8, */*;q=0.1", "Connection": "keep-alive"}
```

[captured result](https://markitdown.dev/evidence/snippets/api-default-headers/result.json)

Pass your own session for headers, timeouts or a proxy:

```python
import requests
from markitdown import MarkItDown

session = requests.Session()
session.headers.update({"User-Agent": "my-pipeline/1.0"})
result = MarkItDown(requests_session=session).convert("http://127.0.0.1:8765/echo-headers")
print(result.markdown)
```

Output · markitdown 0.1.9 · Python 3.13.18 · 2026-11-15

```
{"Host": "127.0.0.1:8765", "User-Agent": "my-pipeline/1.0", "Accept-Encoding": "gzip, deflate", "Accept": "*/*", "Connection": "keep-alive"}
```

[captured result](https://markitdown.dev/evidence/snippets/api-custom-session/result.json) · The server echoes the request headers so you can see exactly what the library sent.

`file:` and `data:` URIs and `requests` responses work too:

```python
import base64, pathlib
from markitdown import MarkItDown

md = MarkItDown()
print(md.convert_uri(pathlib.Path("samples/data.csv").resolve().as_uri()).markdown.splitlines()[0])
payload = base64.b64encode(b"# Hello\n\nFrom a data URI.").decode()
print(md.convert_uri("data:text/markdown;base64," + payload).markdown)
```

Output · markitdown 0.1.9 · Python 3.13.18 · 2026-11-15

```
| station | rainfall_mm | notes |
# Hello

From a data URI.
```

[captured result](https://markitdown.dev/evidence/snippets/api-convert-uri/result.json)

```python
import requests
from markitdown import MarkItDown

response = requests.get("http://127.0.0.1:8765/data.csv")
print("status:", response.status_code, "| content type:", response.headers.get("Content-Type"))
result = MarkItDown().convert_response(response)
print(result.markdown)
```

Output · markitdown 0.1.9 · Python 3.13.18 · 2026-11-15

```
status: 200 | content type: text/csv
| station | rainfall_mm | notes |
| --- | --- | --- |
| Alpha | 412.5 | Battery, low |
| Bravo | 388.0 | OK \| stable |
| Charlie | 451.3 | café |
```

[captured result](https://markitdown.dev/evidence/snippets/api-convert-response/result.json)

Some sites answer 403 to scripts ([web pages](https://markitdown.dev/formats/html/)).

## The result

```python
from markitdown import MarkItDown

result = MarkItDown().convert("samples/report.docx")
print("title:", result.title)
print("markdown is a str:", isinstance(result.markdown, str))
print("text_content is the same text:", result.text_content == result.markdown)
print("str(result) is the same text:", str(result) == result.markdown)
print("attributes:", sorted(a for a in vars(result)))
```

Output · markitdown 0.1.9 · Python 3.13.18 · 2026-11-15

```
title: None
markdown is a str: True
text_content is the same text: True
str(result) is the same text: True
attributes: ['markdown', 'title']
```

[captured result](https://markitdown.dev/evidence/snippets/api-result-object/result.json)

`.markdown` is the text; `text_content` is a deprecated alias and `str(result)` gives the same text. `.title` was `None` for our Word file: it is only set by some formats.

## Handling errors

The exceptions form a small tree:

```python
import markitdown as m

for name in ("MarkItDownException", "MissingDependencyException", "UnsupportedFormatException", "FileConversionException"):
    cls = getattr(m, name)
    print(f"{name:28} bases: {[b.__name__ for b in cls.__bases__]}")
print("FailedConversionAttempt is an exception:", issubclass(m.FailedConversionAttempt, BaseException))
```

Output · markitdown 0.1.9 · Python 3.13.18 · 2026-11-15

```
MarkItDownException          bases: ['Exception']
MissingDependencyException   bases: ['MarkItDownException']
UnsupportedFormatException   bases: ['MarkItDownException']
FileConversionException      bases: ['MarkItDownException']
FailedConversionAttempt is an exception: False
```

[captured result](https://markitdown.dev/evidence/snippets/api-hierarchy/result.json)

Catch them in this order: a missing dependency (tell the user which extra), then an unsupported format, then a failed conversion, where `attempts` holds the real cause:

```python
from markitdown import MarkItDown, FileConversionException, MissingDependencyException

try:
    MarkItDown().convert("samples/pdf-text.pdf")
except FileConversionException as e:
    inner = e.attempts[0].exc_info[1]
    print("outer:", type(e).__name__)
    print("inner:", type(inner).__name__, "| is MissingDependencyException:", isinstance(inner, MissingDependencyException))
    print(str(inner)[:240])
```

Output · markitdown 0.1.9 · Python 3.13.18 · 2026-11-15

```
outer: FileConversionException
inner: MissingDependencyException | is MissingDependencyException: True
PdfConverter recognized the input as a potential .pdf file, but the dependencies needed to read .pdf files have not been installed. To resolve this error, include the optional dependency [pdf] or [all] when installing MarkItDown. For exampl
```

[captured result](https://markitdown.dev/evidence/snippets/api-exceptions-missing-extra/result.json)

```python
from markitdown import MarkItDown, UnsupportedFormatException

try:
    MarkItDown().convert("samples/unsupported.gif")
except UnsupportedFormatException as e:
    print(type(e).__name__)
    print(str(e)[:200])
```

Output · markitdown 0.1.9 · Python 3.13.18 · 2026-11-15

```
UnsupportedFormatException
Could not convert stream to Markdown. No converter attempted a conversion, suggesting that the filetype is simply not supported.
```

[captured result](https://markitdown.dev/evidence/snippets/api-exceptions-unsupported/result.json)

```python
from markitdown import MarkItDown, FileConversionException

try:
    MarkItDown().convert("samples/pdf-encrypted.pdf")
except FileConversionException as e:
    print("message line:", str(e).splitlines()[0])
    for attempt in e.attempts:
        print("converter:", type(attempt.converter).__name__, "| exception:", attempt.exc_info[0].__name__)
```

Output · markitdown 0.1.9 · Python 3.13.18 · 2026-11-15

```
message line: File conversion failed after 1 attempts:
converter: PdfConverter | exception: PDFPasswordIncorrect
```

[captured result](https://markitdown.dev/evidence/snippets/api-exceptions-failed/result.json)

A failed conversion does not break the instance: the next call works.

```python
from markitdown import MarkItDown

md = MarkItDown()
try:
    md.convert("samples/unsupported.gif")
except Exception as e:
    print("first call failed:", type(e).__name__)
print("second call works:", md.convert("samples/data.csv").markdown.splitlines()[0])
```

Output · markitdown 0.1.9 · Python 3.13.18 · 2026-11-15

```
first call failed: UnsupportedFormatException
second call works: | station | rainfall_mm | notes |
```

[captured result](https://markitdown.dev/evidence/snippets/api-error-after-error/result.json)

The meaning of each message is on [the missing-dependency page](https://markitdown.dev/errors/missing-dependency/); scanned PDFs raise no exception at all (they convert to nothing).

## Configuring the converter

| Setting | Where | Page |
| --- | --- | --- |
| Plugins | `MarkItDown(enable_plugins=True)` | [plugins](https://markitdown.dev/plugins/) |
| LLM client, model, prompt | constructor | [image descriptions](https://markitdown.dev/llm/) |
| ExifTool path | `exiftool_path=` | below |
| Word style map | constructor, `style_map=` | [Word](https://markitdown.dev/formats/word/) |
| Azure services | constructor | not tested by us |
| HTTP session | `requests_session=` | [URLs](#urls) |
| Keep image data | per call, `keep_data_uris=True` | below |
| Language, YouTube languages | per call | [audio](https://markitdown.dev/formats/audio/) |

```python
from markitdown import MarkItDown

md = MarkItDown()
short = md.convert("samples/docx-images-no-alt.docx").markdown
full = md.convert("samples/docx-images-no-alt.docx", keep_data_uris=True).markdown
print(len(short), "characters by default")
print(len(full), "characters with keep_data_uris=True")
print(short.splitlines()[2])
print(full.splitlines()[2][:60] + "...")
```

Output · markitdown 0.1.9 · Python 3.13.18 · 2026-11-15

```
103 characters by default
34507 characters with keep_data_uris=True
![](data:image/png;base64...)
![](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAoAAAAFoCA...
```

[captured result](https://markitdown.dev/evidence/snippets/api-keep-data-uris/result.json)

```python
from markitdown import MarkItDown

try:
    MarkItDown(exiftool_path="/definitely/not/here/exiftool").convert("samples/photo-exif.jpg")
except Exception as e:
    print(type(e).__name__)
    print([str(a.exc_info[1])[:90] for a in getattr(e, "attempts", [])])
```

Output · markitdown 0.1.9 · Python 3.13.18 · 2026-11-15

```
FileConversionException
['Failed to invoke exiftool at /definitely/not/here/exiftool: [Errno 2] No such file or dire']
```

[captured result](https://markitdown.dev/evidence/snippets/api-exiftool-path/result.json) · A wrong ExifTool path is an error, not a silent skip.

```python
from markitdown import MarkItDown

plain = MarkItDown().convert("samples/report.docx").markdown.splitlines()[0]
mapped = MarkItDown(style_map="p[style-name='Title'] => h1:fresh").convert("samples/report.docx").markdown.splitlines()[0]
print("default:   ", repr(plain))
print("style_map: ", repr(mapped))
```

Output · markitdown 0.1.9 · Python 3.13.18 · 2026-11-15

```
default:    'Pilot Report: Field Station Alpha'
style_map:  '# Pilot Report: Field Station Alpha'
```

[captured result](https://markitdown.dev/evidence/snippets/api-style-map/result.json)

```python
from markitdown import MarkItDown

md = MarkItDown(enable_plugins=True)     # same as the -p flag of the command line
print(md.convert("samples/notes.txt").markdown.splitlines()[0])
print("installed third-party plugins are loaded from the 'markitdown.plugin' entry-point group")
```

Output · markitdown 0.1.9 · Python 3.13.18 · 2026-11-15

```
Plain text notes.
installed third-party plugins are loaded from the 'markitdown.plugin' entry-point group
```

[captured result](https://markitdown.dev/evidence/snippets/api-plugins/result.json)

Converter order is set by priority; lower numbers run first and the newest registration wins a tie:

```python
from markitdown import DocumentConverter, DocumentConverterResult, MarkItDown, PRIORITY_SPECIFIC_FILE_FORMAT, PRIORITY_GENERIC_FILE_FORMAT

print("PRIORITY_SPECIFIC_FILE_FORMAT =", PRIORITY_SPECIFIC_FILE_FORMAT)
print("PRIORITY_GENERIC_FILE_FORMAT  =", PRIORITY_GENERIC_FILE_FORMAT)

def make(label):
    class C(DocumentConverter):
        def accepts(self, file_stream, stream_info, **kw): return (stream_info.extension or "") == ".txt"
        def convert(self, file_stream, stream_info, **kw): return DocumentConverterResult(markdown=label)
    return C()

md = MarkItDown()
md.register_converter(make("registered first, priority 0"), priority=0.0)
md.register_converter(make("registered second, priority 0"), priority=0.0)
print("equal priority, newest wins:", md.convert("samples/notes.txt").markdown)
md.register_converter(make("registered last, priority 100"), priority=100.0)
print("larger number runs later:", md.convert("samples/notes.txt").markdown)
```

Output · markitdown 0.1.9 · Python 3.13.18 · 2026-11-15

```
PRIORITY_SPECIFIC_FILE_FORMAT = 0.0
PRIORITY_GENERIC_FILE_FORMAT  = 10.0
equal priority, newest wins: registered second, priority 0
larger number runs later: registered second, priority 0
```

[captured result](https://markitdown.dev/evidence/snippets/api-priority/result.json)

```python
from markitdown import DocumentConverter, DocumentConverterResult, MarkItDown, StreamInfo, PRIORITY_SPECIFIC_FILE_FORMAT

class WordCountConverter(DocumentConverter):
    """Turns any .txt file into a one-line word count."""
    def accepts(self, file_stream, stream_info: StreamInfo, **kwargs) -> bool:
        return (stream_info.extension or "").lower() == ".txt"

    def convert(self, file_stream, stream_info: StreamInfo, **kwargs) -> DocumentConverterResult:
        text = file_stream.read().decode(stream_info.charset or "utf-8")
        return DocumentConverterResult(markdown=f"{len(text.split())} words", title="Word count")

md = MarkItDown()
print("before:", md.convert("samples/notes.txt").markdown.splitlines()[0])
md.register_converter(WordCountConverter(), priority=PRIORITY_SPECIFIC_FILE_FORMAT - 1)
result = md.convert("samples/notes.txt")
print("after:", result.markdown, "| title:", result.title)
```

Output · markitdown 0.1.9 · Python 3.13.18 · 2026-11-15

```
before: Plain text notes.
after: 9 words | title: Word count
```

[captured result](https://markitdown.dev/evidence/snippets/api-custom-converter/result.json)

## Performance and reuse

```python
import time
from markitdown import MarkItDown

t = time.perf_counter(); md = MarkItDown(); build = time.perf_counter() - t
times = []
for _ in range(5):
    t = time.perf_counter(); md.convert("samples/report.docx"); times.append(time.perf_counter() - t)
t = time.perf_counter()
for _ in range(5): MarkItDown().convert("samples/report.docx")
fresh = (time.perf_counter() - t) / 5
print(f"construct once: {build:.3f} s")
print(f"first convert: {times[0]:.3f} s, later converts: {min(times[1:]):.3f} to {max(times[1:]):.3f} s")
print(f"new converter for every call: {fresh:.3f} s per conversion")
```

Output · markitdown 0.1.9 · Python 3.13.18 · 2026-11-15

```
construct once: 0.036 s
first convert: 0.230 s, later converts: 0.138 to 0.322 s
new converter for every call: 0.200 s per conversion
```

[captured result](https://markitdown.dev/evidence/snippets/api-reuse-timing/result.json)

Building the converter is cheap (about 0.04 s on our machine) and the first conversion is the slowest, so for small files reuse barely changes the time. Reuse it anyway, because plugins and an LLM client are set up once. One instance shared by eight threads converted 120 files with output identical to the serial run:

```python
import concurrent.futures as cf, hashlib
from markitdown import MarkItDown

files = ["samples/report.docx", "samples/deck.pptx", "samples/workbook.xlsx", "samples/data.csv", "samples/page.html", "samples/pdf-text.pdf"] * 20
md = MarkItDown()
serial = [hashlib.sha256(md.convert(f).markdown.encode()).hexdigest() for f in files]
with cf.ThreadPoolExecutor(8) as pool:
    threaded = list(pool.map(lambda f: hashlib.sha256(md.convert(f).markdown.encode()).hexdigest(), files))
print("conversions:", len(files))
print("identical to the serial run:", serial == threaded)
```

Output · markitdown 0.1.9 · Python 3.13.18 · 2026-11-15

```
conversions: 120
identical to the serial run: True
```

[captured result](https://markitdown.dev/evidence/snippets/api-thread-safety/result.json)

For processes see [batch conversion](https://markitdown.dev/batch/). Notebooks and Colab: we did not test them.

## Warnings and logging

Installing the audio extra makes Python print the ffmpeg warning when the audio library is imported with warnings enabled ([what it means](https://markitdown.dev/errors/ffmpeg/)). Type hints ship with the package.

## Common mistakes

-   Naming your own file `markitdown.py`: it shadows the package.

Reproduced by us

### ImportError: cannot import name 'MarkItDown' from partially initialized module 'markitdown' (most likely due to a circular import)

Your own file is called markitdown.py (or sits in a folder called markitdown), so Python imports it instead of the library. The wording depends on the Python version: 3.10 to 3.12 say 'partially initialized module', 3.13 and later suggest renaming the file.

Affected: any · last reproduced 2026-11-15 · [Upstream report](https://github.com/microsoft/markitdown/issues/8)

-   Using old argument names from older tutorials: on old releases `llm_client` raised a `TypeError` ([error index](https://markitdown.dev/errors/)), and on 0.1.9 the deprecated `file_extension` and `url` arguments of `convert_stream` still work:

```python
import io
from markitdown import MarkItDown

data = open("samples/data.csv", "rb").read()
r1 = MarkItDown().convert_stream(io.BytesIO(data), file_extension=".csv")
r2 = MarkItDown().convert_stream(io.BytesIO(data), url="https://example.org/data.csv")
print(r1.markdown == r2.markdown)
print(r1.markdown.splitlines()[0])
```

Output · markitdown 0.1.9 · Python 3.13.18 · 2026-11-15

```
True
| station | rainfall_mm | notes |
```

[captured result](https://markitdown.dev/evidence/snippets/api-deprecated-args/result.json)

-   Calling `convert` on user input (see the warning above).
-   Printing the result on Windows and redirecting it, instead of writing UTF-8 files ([encoding](https://markitdown.dev/errors/unicodeencodeerror/)).
-   Expecting an exception for a scanned PDF.

## Related

- [Python API reference](https://markitdown.dev/python-api/reference/): Every argument and exception, in reference form.
- [CLI reference](https://markitdown.dev/cli/): The same conversions from the command line.
- [Convert a folder](https://markitdown.dev/batch/): Convert a whole folder, in parallel.
- [MissingDependencyException, FileConversionException, UnsupportedFormatException](https://markitdown.dev/errors/missing-dependency/): Reading MissingDependencyException and friends.
- [LLM image descriptions](https://markitdown.dev/llm/): Image descriptions with an LLM client.

---
Independent guide to the open-source MarkItDown library. Not affiliated with or endorsed by Microsoft. Official source: https://github.com/microsoft/markitdown
