CLI for DocFlow - transform documents between formats with table support
npm install @paulmeller/docflow-cliA command-line interface for DocFlow - transform documents between formats with table support.
- 📄 Convert documents between DOCX, Markdown, HTML, JSON, and plain text
- 📊 Preserve tables when converting DOCX to Markdown
- 🔍 Query document structure using CSS-like selectors
- ✨ Transform content with uppercase, lowercase, titlecase, and sentencecase
- 📋 Extract plain text without formatting
- 🔗 Pipe from stdin for shell scripting integration
``bash`
npm install -g @paulmeller/docflow-cli
docflow --help
`bash`
npx @paulmeller/docflow-cli convert -i document.docx -o document.md
`bash`
git clone
npm install
npm run build
node dist/cli.js --help
- -v, --verbose - Output the SuperDoc JSON structure after conversions (useful for debugging)-V, --version
- - Display CLI version-h, --help
- - Display help information
`bashSee the internal JSON structure after conversion
docflow --verbose convert -i document.docx -o output.md
Commands
$3
Convert documents between formats. Auto-detects format from file extensions.
`bash
DOCX to Markdown (preserves tables!)
docflow convert -i report.docx -o report.mdMarkdown to DOCX
docflow convert -i README.md -o README.docxDOCX to HTML
docflow convert -i document.docx -o document.htmlSpecify output format explicitly
docflow convert -i input.docx -o output.txt -f text
`Options:
-
-i, --input - Input file path (required)
- -o, --output - Output file path (required)
- -f, --format - Output format: docx, markdown, html, json, text (optional)$3
Convert content from stdin to a document. Perfect for piping and shell scripting.
`bash
Pipe markdown to DOCX
echo "# Hello World" | docflow convert-stdin -o output.docxConvert text file to DOCX
cat README.md | docflow convert-stdin -o README.docxGenerate HTML from markdown
echo "## Title\n\nContent" | docflow convert-stdin -o page.html -f html
`Options:
-
-o, --output - Output file path (required)
- -f, --format - Output format: docx, markdown, html, json, text (default: docx)$3
Query document structure using CSS-like selectors.
`bash
Find all headings
docflow query -i document.docx -s "heading"Find level 2 headings only
docflow query -i document.docx -s "heading[level=2]"Count paragraphs
docflow query -i document.docx -s "paragraph" --countExtract heading text
docflow query -i document.docx -s "heading[level=1]" --text
`Options:
-
-i, --input - Input file path (required)
- -s, --selector - CSS-like selector (required)
- -c, --count - Show count only
- -t, --text - Show text content only$3
Transform document content using text transformations.
`bash
Convert all H1 headings to uppercase
docflow transform -i input.docx -o output.docx -s "heading[level=1]" -t uppercaseConvert paragraphs to lowercase
docflow transform -i input.docx -o output.docx -s "paragraph" -t lowercaseApply title case to H2 headings
docflow transform -i input.docx -o output.docx -s "heading[level=2]" -t titlecaseApply sentence case
docflow transform -i input.docx -o output.docx -s "heading" -t sentencecase
`Options:
-
-i, --input - Input file path (required)
- -o, --output - Output file path (required)
- -s, --selector - CSS-like selector (required)
- -t, --type - Transform type: uppercase, lowercase, titlecase, sentencecase (required)$3
Display document structure and table of contents.
`bash
docflow info -i document.docx
`Output example:
`
Document Structure:
==================
Total Headings: 15
- H1: 3
- H2: 8
- H3: 4
Total Paragraphs: 42Table of Contents:
==================
- Introduction
- Overview
- Getting Started
- Features
- Core Features
- Advanced Features
`Options:
-
-i, --input - Input file path (required)$3
Extract plain text from a document without any formatting.
`bash
Print to console
docflow extract-text -i document.docxSave to file
docflow extract-text -i document.docx -o output.txt
`Options:
-
-i, --input - Input file path (required)
- -o, --output - Output text file (optional, prints to console if not specified)Use Cases
$3
`bash
Convert all DOCX files to Markdown
for file in *.docx; do
docflow convert -i "$file" -o "${file%.docx}.md"
doneGenerate report from template
cat report_template.md | docflow convert-stdin -o monthly_report.docx
`$3
`bash
Count headings in a document
docflow query -i document.docx -s "heading" --countExtract all H1 headings
docflow query -i document.docx -s "heading[level=1]" --textGet document structure
docflow info -i document.docx
`$3
`bash
Standardize heading case across multiple files
for file in *.docx; do
docflow transform -i "$file" -o "processed_$file" -s "heading[level=1]" -t titlecase
done
`Supported Formats
| Format | Extension | Read | Write |
|--------|-----------|------|-------|
| Microsoft Word |
.docx | ✅ | ✅ |
| Markdown | .md | ✅ | ✅ |
| HTML | .html | ✅ | ✅ |
| JSON | .json | ✅ | ✅ |
| Plain Text | .txt | ✅ | ✅ |Table Support
DocFlow CLI preserves tables when converting DOCX to Markdown:
DOCX Table:
| Name | Age | City |
|------|-----|------|
| John | 25 | NYC |
| Jane | 30 | LA |
Converts to Markdown:
`markdown
| Name | Age | City |
|------|-----|------|
| John | 25 | NYC |
| Jane | 30 | LA |
``- Node.js 18+ or higher
ISC
- DocFlow - The underlying document transformation library
- SuperDoc - Document processing engine
Issues and pull requests are welcome!