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
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()
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()
str | Path
required
Path to the local file to convert.
StreamInfo
Optional metadata about the file.
DocumentConverterResult
The conversion result.
Example
convert_stream()
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_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()
str
required
URI to convert. Supported schemes:
http://andhttps://: Fetches content via HTTPfile://: Reads local filedata://: 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()
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()
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 formatsPRIORITY_GENERIC_FILE_FORMAT(10.0) for generic/catch-all converters
Example
enable_builtins()
dict
Configuration options passed to converters (llm_client, exiftool_path, etc.).
Example
enable_plugins()
dict
Configuration options passed to plugin converters.
Example
Constants
PRIORITY_SPECIFIC_FILE_FORMAT
PRIORITY_GENERIC_FILE_FORMAT
Built-in Converters
Whenenable_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
Theconvert() methods may raise the following exceptions:
FileConversionException- Converter attempted conversion but failedUnsupportedFormatException- No converter can handle the formatMissingDependencyException- Required dependency not installed