Export a document
export_documentExport a Google Doc to Markdown, HTML, TXT, PDF, DOCX, ODT, RTF, or EPUB; return text formats inline or save any format to an absolute local path without changing the Doc.
Instructions
Exports the document via Drive. Text formats (markdown, txt, html) are returned inline as the tool result — format=markdown is the way to read a doc as Markdown for a round trip with import_markdown. Binary formats (pdf, docx, odt, rtf, epub) require output_path and are written to that local file (the result reports saved_to and bytes); output_path also works for text formats. output_path must be absolute, and an existing file is never overwritten unless overwrite=true. Exports are capped at 10 MB by the Drive API; comments and suggestions are not part of any export. Nothing in Google Docs changes; the only side effect is the local file when output_path is set.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"document_id": "<document_id>",
"format": "<format>"
},
"name": "export_document"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| format | Yes | Target format; markdown/txt/html can be returned inline, the rest need output_path. | |
| overwrite | No | Allow output_path to replace an existing file (default false). | |
| document_id | Yes | The document id — the long id from the document URL (docs.google.com/document/d/<documentId>/edit) or from create_document output. | |
| output_path | No | Absolute local file path to write the export to (required for binary formats). Refused if the file already exists, unless overwrite=true. |