Feishu Document Export Skill
Export Feishu cloud documents or knowledge base documents to local Markdown files, or export them to formats such as PDF/Word.
Core Concepts
Markdown as intermediate state: Conversion between local documents and Feishu cloud documents is done via Markdown format, and intermediate files are stored in the
directory by default.
Usage
bash
# Export regular documents
/feishu-export <document_id>
/feishu-export <document_id> ./output.md
# Export knowledge base documents
/feishu-export <wiki_url>
Execution Flow
-
Parse Parameters
- Determine URL type:
- → Regular document
- → Knowledge base document
- document_id: Required
- output_path: Optional, default
-
Perform Export
Regular document:
bash
feishu-cli doc export <document_id> --output <output_path>
Knowledge base document:
bash
feishu-cli wiki export <node_token> --output <output_path>
-
Verify Result
- Read the exported Markdown file
- Display file size and content preview
Parameter Description
| Parameter | Description | Default Value |
|---|
| document_id/node_token | Document ID or knowledge base node Token | Required |
| output_path | Output file path | |
| --download-images | Download images and whiteboards in the document (whiteboards are automatically exported as PNG) | No |
| --assets-dir | Storage directory for images and whiteboards | |
| --front-matter | Add YAML front matter (title and document ID) | No |
| --highlight | Preserve text color and background color (output as HTML tags) | No |
| --expand-mentions | Expand @user to friendly format (requires contact:user.base:readonly permission) | Yes (enabled by default) |
Supported URL Formats
| URL Format | Type | Command |
|---|
https://xxx.feishu.cn/docx/<id>
| Regular document | |
https://xxx.feishu.cn/wiki/<token>
| Knowledge base | |
https://xxx.larkoffice.com/docx/<id>
| Regular document | |
https://xxx.larkoffice.com/wiki/<token>
| Knowledge base | |
Output Format
Document exported successfully!
File path: /path/to/output.md
File size: 2.5 KB
Content preview:
---
# Document Title
...
Examples
bash
# Export regular document
/feishu-export <document_id>
/feishu-export <document_id> ~/Documents/doc.md
# Export knowledge base document
/feishu-export https://xxx.feishu.cn/wiki/<node_token>
/feishu-export <node_token> ./wiki_doc.md
# Export and download images
/feishu-export <document_id> --download-images
# Export and add YAML front matter
/feishu-export <document_id> -o doc.md --front-matter
# Export and preserve text highlight color
/feishu-export <document_id> -o doc.md --highlight
Front Matter Output Format
When using
, the following content will be added to the top of the exported Markdown file:
yaml
---
title: "Document Title"
document_id: ABC123def456
---
Highlight Color Output Format
When using
, colored text will be output as HTML
tags:
html
<span style="color: #ef4444">Red text</span>
<span style="background-color: #eff6ff">Blue highlighted background</span>
Supported colors: 7 font colors (red/orange/yellow/green/blue/purple/gray) + 14 background colors (7 light and 7 dark each).
Image Processing (Important)
Be sure to download images when exporting documents for subsequent content understanding:
Export and Download Images
bash
# Regular document
feishu-cli doc export <document_id> \
--output /tmp/doc.md \
--download-images \
--assets-dir /tmp/doc_assets
# Knowledge base document
feishu-cli wiki export <node_token> \
--output /tmp/wiki.md \
--download-images \
--assets-dir /tmp/wiki_assets
View and Understand Images
bash
# View list of downloaded images
ls -la /tmp/doc_assets/
# Read images with Read tool (Claude supports multimodal)
# Read /tmp/doc_assets/image_1.png
# Read /tmp/doc_assets/image_2.png
Complete Process
- Add image parameters when exporting:
--download-images --assets-dir <dir>
- Check image files:
- Read image content: Read images one by one with Read tool
- Integrated analysis: Combine image descriptions with document text
Error Handling and Edge Cases
1. Common Errors
| Error | Cause | Solution |
|---|
| Parameter error | Check token format |
code=131001, node not found
| Node does not exist | Check if the token is correct |
code=131003, no permission
| No access permission | Confirm the application has docx:document or wiki:wiki:readonly permission |
code=99991672, open api request rate limit
| API rate limit | Retry after a few seconds |
write /tmp/xxx.md: permission denied
| File permission issue | Check output directory permission, change output path |
2. Edge Case Handling
Case 1: Directory node export
- The exported content of knowledge base directory nodes may show as
- This is normal behavior, indicating that the node is a directory instead of an actual document
- Use
wiki nodes <space_id> --parent <token>
to get child nodes
Case 2: Empty document content
- Check if the document is actually empty
- Check if you have permission to view the content
- Check if it is a directory node
Case 3: Image download failed
- Check if the directory exists and is writable
- Check network connection
- The image may have been deleted or you have insufficient permissions
Case 4: Export interrupted
- Large document export may take a long time
- If interrupted, you can re-execute the command
- Use to specify a fixed path for resumable transfer
3. Retry Mechanism
If you encounter network errors or API rate limits:
bash
# Add --debug to view detailed error information
feishu-cli doc export <doc_id> --debug
# Retry after waiting for a few seconds
sleep 5 && feishu-cli doc export <doc_id>
Known Issues
| Issue | Description |
|---|
| Table export | Cell content in tables may show as <!-- Unknown block type: 32 -->
, this is a known conversion issue for block type 32 (table cell) |
| Directory node | Exported content of knowledge base directory nodes is , need to get child nodes separately |
Supported Export Block Types
| Feishu Block Type | Export Result | Description |
|---|
| Heading (Heading 1-6) | | |
| Heading (Heading 7-9) | or bold paragraph | Degraded when exceeding H6 |
| Paragraph (Text) | Plain text | |
| Unordered list (Bullet) | | Supports unlimited depth nesting |
| Ordered list (Ordered) | | Preserve original numbering sequence |
| Task list (Todo) | / | |
| Code block (Code) | | Use original text, no escaping |
| Quote (Quote) | | |
| Quote container (QuoteContainer) | | Supports nested quotes |
| Callout block | | 6 types |
| Formula (Equation) | | Block-level formula |
| Inline formula | | Inline formula in paragraph |
| Divider (Divider) | | |
| Table (Table) | Markdown table | Pipe characters are automatically escaped |
| Image (Image) | | |
| Link | | URL special characters are automatically encoded |
| Whiteboard (Board) | [Whiteboard](feishu://board/...)
or PNG image | Automatically exported as PNG when using |
| ISV block | Whiteboard link or HTML comment | Mermaid drawing/timeline |
| Iframe | HTML tag | Embedded content |
| AddOns/SyncedBlock | Expand child block content | Transparent expansion |
| Wiki directory | | |
| Agenda/AgendaItem | Expand child block content | Agenda block |
| LinkPreview | Link | Link preview |
| SyncSource/SyncReference | Expand child block content | Sync block |
| WikiCatalogV2 | [Knowledge Base Directory V2]
| |
| AITemplate | HTML comment | AI template block |
Callout Block Export
Callout blocks (Feishu highlight blocks) are exported as GitHub-style alert syntax:
markdown
> [!NOTE]
> This is a note message.
> [!WARNING]
> This is a warning message.
Supports 6 Callout types (mapped by background color):
| Background Color | Export Type | Description |
|---|
| 2 (Red) | | Warning |
| 3 (Orange) | | Caution |
| 4 (Yellow) | | Tip |
| 5 (Green) | | Success |
| 6 (Blue) | | Note |
| 7 (Purple) | | Important |
Child blocks inside Callout (paragraphs, lists, etc.) will be displayed line by line within the quote syntax.
Formula Export
- Block-level formula: Independent line
- Inline formula: Inline in paragraph
- Formula content retains original LaTeX text, no escaping
Special Character Handling
The following Markdown special characters are automatically processed during export:
- in plain text will be automatically escaped with
- Text in code blocks is not escaped (uses original text)
- in table cells will be escaped to
- Parentheses in URLs will be encoded to
Verified Features
The following export functions have passed test verification:
- Regular document export ✅
- Knowledge base document export ✅
- Headings, paragraphs, lists (including nested lists), code blocks, quotes, dividers ✅
- Task list (Todo) ✅
- Image download ✅ (use )
- Callout highlight blocks (6 types) ✅
- Formulas (block-level + inline) ✅
- Front Matter ✅ (use )
- Text highlight color ✅ (use )
- ISV blocks (Mermaid drawing) ✅
- AddOns/SyncedBlock expansion ✅
- Special character escaping ✅
- @User expansion ✅ (use , enabled by default)
- New block types (Agenda/LinkPreview/SyncBlock/WikiCatalogV2/AITemplate) ✅
- Table structure ⚠️ (content may be lost)
- Feishu whiteboard → whiteboard link/PNG image ✅
Two-way Conversion Description
| Import (Markdown → Feishu) | Export (Feishu → Markdown) |
|---|
| Mermaid/PlantUML code block → Feishu whiteboard | Feishu whiteboard → whiteboard link/PNG image |
| Large table → automatically split into multiple tables | Multiple tables → separate tables |
| Indented list → nested parent-child blocks | Nested list → indented Markdown |
| → Callout highlight block | Callout highlight block → |
| → inline formula | Inline/block-level formula → |
| → underline style | Underline style → |
Note: Mermaid/PlantUML charts will be converted to Feishu whiteboards after import, and the exported result is a whiteboard link instead of the original chart code.
Asynchronous Export to PDF/Word/Excel (doc export-file)
Export Feishu cloud documents to PDF, Word and other formats (three-step asynchronous process):
Execution Flow
bash
# One command to complete the whole process (automatically create task → poll → download internally)
feishu-cli doc export-file <doc_token> --type pdf -o output.pdf
Supported Export Formats
| --type | Format | Description |
|---|
| PDF | Preserve typesetting |
| Word | Editable |
Parameters
| Parameter | Description | Default Value |
|---|
| Document Token | Required |
| Export format | Required |
| Output file path | Required |
Examples
bash
# Export as PDF
feishu-cli doc export-file JKbxdRez1oNWEKxPz14cWMpBnKh --type pdf -o /tmp/report.pdf
# Export as Word
feishu-cli doc export-file JKbxdRez1oNWEKxPz14cWMpBnKh --type docx -o /tmp/report.docx
Import Local Files to Feishu Cloud Documents (doc import-file)
Import local DOCX/XLSX and other files into Feishu cloud documents (asynchronous process):
Execution Flow
bash
# One command to complete the whole process (automatically upload → create task → poll internally)
feishu-cli doc import-file local_file.docx --type docx --name "Document Name"
Supported Import Formats
| --type | Format | Description |
|---|
| Word document | Convert to Feishu document |
Parameters
| Parameter | Description | Default Value |
|---|
| Local file path | Required |
| File type | Required |
| Feishu document name | File name |
Examples
bash
# Import Word document
feishu-cli doc import-file ~/Documents/report.docx --type docx --name "Quarterly Report"