Convert document to markdown
convert_document_to_markdownConvert a document you already have (PDF, DOCX, HTML, plain text) to clean, LLM-ready markdown. Pass the file contents as base64. Supports reading only part of a large document: PDF page ranges, a heading outline, a single section, or a token cap.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| mode | No | "full" (default) returns the document body. "outline" returns just the heading tree — each line is `- [#3] Heading text (~120 tokens)`. For a long document, call with mode: 'outline' first, then fetch only what you need with section: '#3' or a heading title. | |
| pages | No | PDFs only: 1-indexed, inclusive page ranges to convert, e.g. "1-3,5,8-" (an open-ended range runs to the last page). Ignored with a warning for non-PDF formats. | |
| base64 | Yes | Base64-encoded file contents | |
| section | No | Return only one section: either "#<n>" using the index from a mode: 'outline' call (e.g. '#3'), or the heading text itself (case-insensitive; exact match wins, then prefix, then substring). Ignored when mode is 'outline'. | |
| filename | No | Original filename, e.g. report.pdf — helps format detection | |
| maxTokens | No | Cap the returned markdown at roughly this many tokens, cutting at a paragraph boundary. When the output is cut, the result starts with a `> Truncated: ~X of ~Y tokens` line — narrow with pages or section rather than raising this. |