English | 简体中文
AnyToMarkdown is a powerful online tool that quickly and accurately converts various document formats (including PDF files, images, HTML pages, etc.) to Markdown format. The service is built on Cloudflare Workers AI, providing high-performance, low-latency file conversion experience.
Live Demo: https://cf-anytomarkdown.vercel.app/
- Multi-format Support: Convert PDF, HTML, images, and other formats to Markdown
- File Upload: Support drag-and-drop or file selection for conversion
- Format Preservation: Maintains original document formatting including headings, lists, tables, images, etc.
- Real-time Preview: Instantly preview conversion results
- Export & Download: Easily download generated Markdown files
AnyToMarkdown uses a monorepo structure with the following main components:
packages/web
: Frontend React application providing the user interfacepackages/worker
: Cloudflare Worker backend handling file conversion logic
Before using AnyToMarkdown, you need:
- A Cloudflare account
- Node.js v18 or higher
- npm or yarn
git clone https://github.com/yourusername/anytomarkdown.git
cd anytomarkdown
npm install
- In the
packages/worker
directory, copy the example configuration file:
cp packages/worker/wrangler.example.toml packages/worker/wrangler.toml
- Edit the
packages/worker/wrangler.toml
file, adding your Cloudflare account ID:
# Add your Cloudflare account ID here
account_id = "your_account_id_here" # Replace with your actual account ID
- Create a
.dev.vars
file in thepackages/worker
directory for local development environment variables:
# Example .dev.vars file
ENVIRONMENT=development
CORS_ALLOWED_ORIGINS=http://localhost:5173
MAX_FILE_SIZE=10485760 # 10MB in bytes
ENABLE_DEBUG=true
The .dev.vars
file is used to store environment variables for local development.
You can find your account ID in the Cloudflare Dashboard.
- In the
packages/web
directory, copy the example environment file:
cp packages/web/.env.example packages/web/.env.local
- Edit the
.env.local
file according to your needs:- Use local Worker URL for development
- Use deployed Worker URL for production
Start the frontend development server:
npm run dev:web
Start the Worker development server:
npm run dev:worker
Or start both simultaneously:
npm run dev
npm run build
After configuring your wrangler.toml
file, run:
npm run deploy:worker
To deploy the frontend to Vercel, follow these steps:
-
Install Vercel CLI (optional):
npm install -g vercel
-
Login to Vercel:
vercel login
-
Deploy the Frontend: Navigate to the
packages/web
directory and run:vercel
-
Configure Environment Variables:
- Set the
VITE_API_BASE_URL
to your deployed Worker URL in the Vercel project settings.
- Set the
Build and deploy the entire project:
npm run deploy
- Visit the AnyToMarkdown website
- Drag and drop files to the designated area or click "Choose File"
- After uploading, the system will automatically begin conversion
- Once complete, preview the Markdown content in the preview area
- Click "Download" to save the Markdown file
AnyToMarkdown provides RESTful APIs allowing developers to integrate conversion functionality into their applications:
Request:
POST /api/convert
Content-Type: multipart/form-data
File field name: file
Response:
{
"success": true,
"result": {
"name": "filename",
"mimeType": "text/markdown",
"format": "markdown",
"tokens": 1234,
"data": "# Markdown content..."
}
}
Request:
POST /api/batch-convert
Content-Type: multipart/form-data
File field names: file1, file2, ...
Response:
{
"success": true,
"results": [
{
"name": "filename1",
"mimeType": "text/markdown",
"format": "markdown",
"tokens": 1234,
"data": "# Markdown content..."
},
{
"name": "filename2",
"mimeType": "text/markdown",
"format": "markdown",
"tokens": 5678,
"data": "# Another Markdown content..."
}
]
}
Request:
GET /api/status
Response:
{
"success": true,
"status": "online",
"service": "anytomarkdown",
"version": "1.0.0"
}
AnyToMarkdown utilizes Cloudflare Workers AI's toMarkdown conversion functionality, supporting various document formats:
- PDF Documents: Converts PDF files to Markdown while preserving structure
- Images: Uses AI to describe image content and convert to meaningful Markdown text
- HTML Documents: Transforms HTML pages into clean Markdown
- XML Documents: Converts XML data to Markdown format
- Spreadsheets: Handles various spreadsheet formats (Excel, CSV, etc.)
AnyToMarkdown supports the following file formats:
- PDF Documents (.pdf)
- Images (.jpeg, .jpg, .png, .webp, .svg)
- HTML Documents (.html)
- XML Documents (.xml)
- Microsoft Office Spreadsheets (.xlsx, .xlsm, .xlsb, .xls)
- OpenDocument Spreadsheets (.ods)
- CSV Files (.csv)
- Apple Numbers Files (.numbers)
- Maximum File Size: 5MB per file
- AI Processing Limits: Cloudflare Workers AI has internal processing limits that may result in errors for complex files even below the size limit
- Error Handling: The application includes proper error handling for oversized files and service unavailability
Note: The Markdown Conversion feature in Cloudflare Workers AI is currently in Beta stage. This means:
- The conversion quality may not be perfect in all cases
- Complex formatting might be lost during conversion
- Results may vary depending on the input document complexity
- The service is subject to changes and improvements by Cloudflare
We recommend reviewing and possibly editing the converted Markdown for critical documents.
We welcome community contributions! If you'd like to contribute to AnyToMarkdown, please follow these steps:
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Frontend: React, TypeScript, Tailwind CSS, Vite
- Backend: Cloudflare Workers, TypeScript
- Conversion Engine: Cloudflare Workers AI