Skip to main content

talonic_to_markdown

Get OCR-converted markdown for a document. Accepts document_id (cheapest — no re-upload), file_data + filename, file_path, or file_url.

`talonic_to_markdown` converts a document's visual content into clean, structured markdown. Tables are rendered as markdown tables, headings are preserved, and the text is ordered to match the visual layout of the original document. This is the right tool when the user wants the full text of a document for summarisation, translation, or general analysis without needing structured field extraction.

If you have already ingested the document (via a previous talonic_extract or talonic_to_markdown call), pass the document_id to skip re-uploading. This is the cheapest and fastest path because the OCR has already been performed. For new documents, use file_data + filename in chat clients, file_path for local files, or file_url for remote files.

The returned markdown is suitable for feeding into an LLM's context window for downstream tasks. Because the conversion preserves table structure and heading hierarchy, the LLM can reason about the document's content without losing structural information that raw text extraction would discard.

ParameterTypeDescription
document_idstringID of an already-ingested document (cheapest path).
file_datastringBase64-encoded file bytes. Pair with `filename`.
filenamestringOriginal filename with extension.
file_pathstringLocal file path.
file_urlstringRemote URL the API fetches server-side.
If you need both structured data and markdown, use talonic_extract with include_markdown: true instead of making two separate calls. This saves one upload and one processing cycle.

Example

Tool input
{
  "document_id": "doc_8f3a1b2c-4d5e-6f7a-8b9c-0d1e2f3a4b5c"
}
Tool response
# Invoice INV-2026-001

**Meridian Energy AG**
Musterstraße 42, 10115 Berlin

| Item                  | Amount     |
|-----------------------|------------|
| Consulting — April    | €1,200.00  |
| Travel expenses       | €300.00    |
| **Total**             | **€1,500.00** |

Due date: 15 June 2026
Payment terms: Net 30

Example: convert from URL

Tool input: convert a remote PDF to markdown
{
  "file_url": "https://example.com/annual-report-2025.pdf"
}
Tool response: structured markdown output
# Annual Report 2025

## Financial Highlights

| Metric              | 2025       | 2024       | Change  |
|---------------------|------------|------------|---------|
| Revenue             | €12.4M     | €9.8M      | +26.5%  |
| Net Income          | €2.1M      | €1.4M      | +50.0%  |
| Employees           | 142        | 98         | +44.9%  |

## Board of Directors

- **Chair**: Dr. Maria Fischer
- **CEO**: Thomas Bergmann
- **CFO**: Sarah Lindqvist

The markdown output is designed to be LLM-friendly. Agents can feed the returned markdown directly into their context window for summarisation, translation, comparison, or question-answering tasks. Because the conversion preserves semantic structure (headings denote sections, tables retain rows and columns, lists maintain hierarchy), downstream LLM reasoning is significantly more accurate than working with raw OCR text that has lost all formatting cues.

For multi-page documents, the markdown includes page break indicators and preserves the reading order across pages. Headers, footers, and page numbers are typically stripped or de-duplicated to produce a clean reading experience. If the document contains images with embedded text (like scanned letterheads or stamps), the OCR engine extracts visible text from those regions as well, though image-only content without text is omitted from the markdown output.

When an agent needs to compare two versions of a document, talonic_to_markdown is the right starting point. Convert both documents to markdown, then use standard text diffing within the agent's context to identify changes. This is more reliable than visual comparison because the markdown normalises formatting differences and focuses on content. The stable document IDs make it easy to retrieve markdown for previously processed documents without re-uploading.

Frequently asked questions

How do I get markdown from a document via MCP?+
Call talonic_to_markdown with a document_id (cheapest), or provide the file directly via file_data, file_path, or file_url.
Does talonic_to_markdown preserve table structure?+
Yes. Tables are rendered as markdown tables with proper column alignment. Headings and text ordering are also preserved to match the original document layout.
Should I use talonic_to_markdown or talonic_extract with include_markdown?+
If you only need the text, use talonic_to_markdown. If you need both structured fields and the full text, use talonic_extract with include_markdown: true to avoid two separate calls.
Can I use talonic_to_markdown for document comparison?+
Yes. Convert both document versions to markdown, then diff the text in the agent's context. Markdown normalises formatting differences and focuses on content, making comparison more reliable than visual methods. Use document_id for previously processed files to avoid re-uploading.
Does talonic_to_markdown handle scanned documents?+
Yes. The tool runs OCR on scanned PDFs, images (PNG, JPG, TIFF), and other image-based documents. Text is extracted from all visible regions including headers, stamps, and handwritten annotations where legible. The output is clean markdown regardless of whether the source is digital or scanned.