Skip to main content
The MarkItDown class is the primary interface for converting various document formats to Markdown. It manages converter registration, file type detection, and the conversion process.

Constructor

Create a new MarkItDown instance.
bool | None
default:"True"
Enable built-in converters. When None or True, built-in converters are automatically registered.
bool | None
default:"False"
Enable plugin converters. When True, converters from installed plugins are registered.
requests.Session
Custom requests session for HTTP operations. If not provided, a default session is created with appropriate Accept headers.
Any
LLM client instance for converters that support AI-powered conversion.
str
Model name to use with the LLM client.
str
Custom prompt to use with LLM-based converters.
str
Path to the exiftool binary for image metadata extraction. If not provided, searches common system paths.
str
Custom style map for DOCX conversion.
str
Azure Document Intelligence endpoint URL. When provided, enables the Document Intelligence converter.
Any
Credentials for Azure Document Intelligence.
list
File types to process with Document Intelligence.
str
API version for Document Intelligence service.

Example

Methods

convert()

Convert a document from various source types to Markdown.
str | requests.Response | Path | BinaryIO
required
The source to convert. Can be:
  • Local file path (str or Path)
  • URL string (http://, https://, file://, data://)
  • requests.Response object
  • Binary file-like object (BinaryIO)
StreamInfo
Optional metadata about the source. If not provided, MarkItDown attempts to infer it.
DocumentConverterResult
The conversion result containing the Markdown text and optional metadata.

Example

convert_local()

Convert a local file to Markdown.
str | Path
required
Path to the local file to convert.
StreamInfo
Optional metadata about the file.
DocumentConverterResult
The conversion result.

Example

convert_stream()

Convert a binary stream to Markdown.
BinaryIO
required
Binary file-like object to convert. Must support read() method. If not seekable, the stream is loaded into memory.
StreamInfo
Optional metadata about the stream. Used for format detection.
DocumentConverterResult
The conversion result.

Example

convert_url()

Convert a URL to Markdown. This is an alias for convert_uri().
str
required
URL to convert (http://, https://, file://, or data://).
StreamInfo
Optional metadata override.
str
Pretend the content came from this URL instead (for converter routing).
DocumentConverterResult
The conversion result.

Example

convert_uri()

Convert a URI to Markdown. Supports http://, https://, file://, and data:// schemes.
str
required
URI to convert. Supported schemes:
  • http:// and https://: Fetches content via HTTP
  • file://: Reads local file
  • data://: Decodes data URI
StreamInfo
Optional metadata override.
str
Mock the request as if it came from a different URL.
DocumentConverterResult
The conversion result.

Example

convert_response()

Convert an HTTP response to Markdown.
requests.Response
required
HTTP response object from the requests library.
StreamInfo
Optional metadata override. By default, metadata is extracted from response headers.
DocumentConverterResult
The conversion result.

Example

register_converter()

Register a custom document converter.
DocumentConverter
required
The converter instance to register.
float
default:"0.0"
Converter priority. Lower values are tried first. Use:
  • PRIORITY_SPECIFIC_FILE_FORMAT (0.0) for specific formats
  • PRIORITY_GENERIC_FILE_FORMAT (10.0) for generic/catch-all converters

Example

enable_builtins()

Enable and register built-in converters. Built-in converters are enabled by default. This method should only be called once if built-ins were initially disabled.
dict
Configuration options passed to converters (llm_client, exiftool_path, etc.).

Example

enable_plugins()

Enable and register converters provided by installed plugins. Plugins are disabled by default. This method should only be called once if plugins were initially disabled.
dict
Configuration options passed to plugin converters.

Example

Constants

PRIORITY_SPECIFIC_FILE_FORMAT

Priority value for converters that handle specific file formats (e.g., .docx, .pdf, .xlsx) or specific websites (e.g., Wikipedia, YouTube).

PRIORITY_GENERIC_FILE_FORMAT

Priority value for near catch-all converters that handle generic mimetypes (e.g., text/*, application/zip, text/html).

Built-in Converters

When enable_builtins=True (default), the following converters are automatically registered:
  • PlainTextConverter - Plain text files (priority 10.0)
  • HtmlConverter - HTML documents (priority 10.0)
  • ZipConverter - ZIP archives (priority 10.0)
  • RssConverter - RSS feeds
  • WikipediaConverter - Wikipedia pages
  • YouTubeConverter - YouTube videos
  • BingSerpConverter - Bing search results
  • DocxConverter - Microsoft Word documents
  • XlsxConverter - Excel spreadsheets (.xlsx)
  • XlsConverter - Excel spreadsheets (.xls)
  • PptxConverter - PowerPoint presentations
  • PdfConverter - PDF documents
  • ImageConverter - Image files with OCR
  • AudioConverter - Audio files with transcription
  • IpynbConverter - Jupyter notebooks
  • OutlookMsgConverter - Outlook email messages
  • EpubConverter - EPUB ebooks
  • CsvConverter - CSV files
  • DocumentIntelligenceConverter - Azure Document Intelligence (when endpoint provided)

Error Handling

The convert() methods may raise the following exceptions:
  • FileConversionException - Converter attempted conversion but failed
  • UnsupportedFormatException - No converter can handle the format
  • MissingDependencyException - Required dependency not installed