| Crates.io | undoc |
| lib.rs | undoc |
| version | 0.1.10 |
| created_at | 2025-12-20 13:17:52.488725+00 |
| updated_at | 2025-12-21 12:57:43.695+00 |
| description | High-performance Microsoft Office document extraction to Markdown |
| homepage | |
| repository | https://github.com/iyulab/undoc |
| max_upload_size | |
| id | 1996500 |
| size | 369,512 |
A high-performance Rust library for extracting content from Microsoft Office documents (DOCX, XLSX, PPTX) to Markdown, plain text, and JSON.
Download the latest release from GitHub Releases.
# Download and extract
Invoke-WebRequest -Uri "https://github.com/iyulab/undoc/releases/latest/download/undoc-cli-x86_64-pc-windows-msvc.zip" -OutFile "undoc.zip"
Expand-Archive -Path "undoc.zip" -DestinationPath "."
# Move to a directory in PATH (optional)
Move-Item -Path "undoc.exe" -Destination "$env:LOCALAPPDATA\Microsoft\WindowsApps\"
# Verify installation
undoc version
# Download and extract
curl -LO https://github.com/iyulab/undoc/releases/latest/download/undoc-cli-x86_64-unknown-linux-gnu.tar.gz
tar -xzf undoc-cli-x86_64-unknown-linux-gnu.tar.gz
# Install to /usr/local/bin (requires sudo)
sudo mv undoc /usr/local/bin/
# Or install to user directory
mkdir -p ~/.local/bin
mv undoc ~/.local/bin/
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
# Verify installation
undoc version
# Intel Mac
curl -LO https://github.com/iyulab/undoc/releases/latest/download/undoc-cli-x86_64-apple-darwin.tar.gz
tar -xzf undoc-cli-x86_64-apple-darwin.tar.gz
# Apple Silicon (M1/M2/M3)
curl -LO https://github.com/iyulab/undoc/releases/latest/download/undoc-cli-aarch64-apple-darwin.tar.gz
tar -xzf undoc-cli-aarch64-apple-darwin.tar.gz
# Install
sudo mv undoc /usr/local/bin/
# Verify
undoc version
| Platform | Architecture | File |
|---|---|---|
| Windows | x64 | undoc-cli-x86_64-pc-windows-msvc.zip |
| Linux | x64 | undoc-cli-x86_64-unknown-linux-gnu.tar.gz |
| macOS | Intel | undoc-cli-x86_64-apple-darwin.tar.gz |
| macOS | Apple Silicon | undoc-cli-aarch64-apple-darwin.tar.gz |
undoc includes a built-in self-update mechanism:
# Check for updates
undoc update --check
# Update to latest version
undoc update
# Force reinstall (even if on latest)
undoc update --force
If you have Rust installed:
# Install CLI
cargo install undoc-cli
# Add library to your project
cargo add undoc
# Extract all formats (Markdown, text, JSON) + media to output directory
undoc document.docx
# Specify output directory
undoc document.docx ./output
# With text cleanup for LLM training
undoc document.docx --cleanup aggressive
document_output/
├── extract.md # Markdown output with frontmatter
├── extract.txt # Plain text output
├── content.json # Full structured JSON
└── media/ # Extracted images and media
└── image1.jpeg
undoc <file> [output] # Extract all formats (default)
undoc convert <file> [OPTIONS] # Same as above, explicit command
undoc markdown <file> [OPTIONS] # Convert to Markdown only (alias: md)
undoc text <file> [OPTIONS] # Convert to plain text only
undoc json <file> [OPTIONS] # Convert to JSON only
undoc info <file> # Show document information
undoc extract <file> [OPTIONS] # Extract resources only
undoc update [OPTIONS] # Self-update to latest version
undoc version # Show version information
# Basic conversion (output to stdout)
undoc markdown document.docx
# Save to file
undoc markdown document.docx -o output.md
# With YAML frontmatter
undoc markdown document.docx --frontmatter -o output.md
# With text cleanup for LLM training
undoc markdown document.docx --cleanup standard -o cleaned.md
# Table rendering options
undoc markdown spreadsheet.xlsx --table-mode html -o output.md
# Limit heading depth
undoc markdown document.docx --max-heading 3 -o output.md
| Option | Description | Default |
|---|---|---|
-o, --output |
Output file path | stdout |
-f, --frontmatter |
Include YAML frontmatter | false |
--table-mode |
Table rendering: markdown, html, ascii |
markdown |
--cleanup |
Text cleanup: minimal, standard, aggressive |
none |
--max-heading |
Maximum heading level (1-6) | 6 |
# Basic extraction
undoc text document.docx
# With cleanup
undoc text document.docx --cleanup standard -o output.txt
# Pretty-printed JSON
undoc json document.docx -o output.json
# Compact JSON
undoc json document.docx --compact -o output.json
undoc info document.docx
Output:
Document Information
────────────────────────────────────────
File: document.docx
Format: Docx
Sections: 5
Resources: 3
Title: My Document
Author: John Doe
Pages/Slides/Sheets: 10
Created: 2025-01-15T10:30:00Z
Modified: 2025-01-20T14:45:00Z
Content Statistics
────────────────────────────────────────
Words: 2500
Characters: 15000
# Extract to current directory
undoc extract presentation.pptx
# Extract to specific directory
undoc extract presentation.pptx -o ./media
# Check for updates
undoc update --check
# Update to latest version
undoc update
# Force reinstall
undoc update --force
# Convert Word document to Markdown with frontmatter
undoc md report.docx --frontmatter -o report.md
# Convert Excel to Markdown tables
undoc md data.xlsx -o tables.md
# Convert PowerPoint to Markdown
undoc md presentation.pptx -o slides.md
# Extract all images from a document
undoc extract report.docx -o ./images
# Get document metadata
undoc info document.docx
# Convert with aggressive cleanup for AI training
undoc md document.docx --cleanup aggressive -o cleaned.md
# Batch conversion (shell)
for f in *.docx; do undoc md "$f" -o "${f%.docx}.md"; done
# Batch conversion (PowerShell)
Get-ChildItem *.docx | ForEach-Object { undoc md $_.FullName -o "$($_.BaseName).md" }
use undoc::{parse_file, render};
fn main() -> undoc::Result<()> {
// Parse document
let doc = parse_file("document.docx")?;
// Convert to Markdown
let options = render::RenderOptions::default();
let markdown = render::to_markdown(&doc, &options)?;
println!("{}", markdown);
// Get plain text
let text = render::to_text(&doc, &options)?;
// Get JSON
let json = render::to_json(&doc, render::JsonFormat::Pretty)?;
Ok(())
}
use undoc::render::{RenderOptions, CleanupPreset, TableFallback};
let options = RenderOptions::new()
.with_frontmatter(true)
.with_table_fallback(TableFallback::Html)
.with_cleanup_preset(CleanupPreset::Aggressive)
.with_max_heading(3);
let markdown = render::to_markdown(&doc, &options)?;
use undoc::parse_file;
let doc = parse_file("document.docx")?;
// Access metadata
println!("Title: {:?}", doc.metadata.title);
println!("Author: {:?}", doc.metadata.author);
println!("Created: {:?}", doc.metadata.created);
// Iterate sections
for section in &doc.sections {
println!("Section: {:?}", section.name);
for element in §ion.elements {
// Process paragraphs, tables, etc.
}
}
// Extract resources
for (id, resource) in &doc.resources {
let filename = resource.suggested_filename(id);
std::fs::write(&filename, &resource.data)?;
}
use undoc::{detect_format_from_path, detect_format_from_bytes, FormatType};
// From file path
let format = detect_format_from_path("document.docx")?;
assert_eq!(format, FormatType::Docx);
// From bytes
let data = std::fs::read("document.docx")?;
let format = detect_format_from_bytes(&data)?;
undoc provides C-ABI compatible bindings for integration with C# and .NET applications.
Download from GitHub Releases:
| Platform | Library File |
|---|---|
| Windows x64 | undoc.dll |
| Linux x64 | libundoc.so |
| macOS | libundoc.dylib |
Or build from source:
cargo build --release --features ffi
using Undoc;
// Parse and convert to Markdown
string markdown = UndocNative.ToMarkdown("document.docx");
// Parse and convert to plain text
string text = UndocNative.ToText("document.docx");
// Parse and convert to JSON
string json = UndocNative.ToJson("document.docx");
// From byte array
byte[] data = File.ReadAllBytes("document.docx");
string markdown = UndocNative.ToMarkdownFromBytes(data);
See bindings/csharp/Undoc.cs for the complete wrapper implementation.
Structured Markdown with preserved formatting:
#, ##, ###**), italic (*), underline, strikethroughPure text content without formatting markers.
Complete document structure with metadata:
{
"metadata": {
"title": "Document Title",
"author": "Author Name",
"created": "2025-01-15T10:30:00Z",
"modified": "2025-01-20T14:45:00Z"
},
"sections": [...],
"resources": [...]
}
| Format | Extension | Status |
|---|---|---|
| Word | .docx | Supported |
| Excel | .xlsx | Supported |
| PowerPoint | .pptx | Supported |
| Feature | Description | Default |
|---|---|---|
ffi |
C-ABI foreign function interface | No |
# Cargo.toml - enable FFI
[dependencies]
undoc = { version = "0.1", features = ["ffi"] }
MIT License - see LICENSE for details.
Contributions are welcome! Please feel free to submit a Pull Request.