MegaConvert API
Convert files between 500+ formats with a single HTTP request. No SDKs, no libraries, no dependencies. Just curl.
Introduction
The MegaConvert API lets you convert files between 500+ formats programmatically. Documents, images, videos, audio, ebooks, archives — all through a simple REST API.
Base URL: https://megaconvert.io/api/v1
Quick Start
Convert a file in one command. No SDK needed.
curl:
curl -X POST https://megaconvert.io/api/v1/convert/sync \
-H "X-API-Key: YOUR_API_KEY" \
-F "file=@document.docx" \
-F "output_format=pdf" \
-o document.pdf
That's it. The converted file is saved as document.pdf. No polling, no callbacks, no waiting.
Authentication
All API requests (except /formats and /tools) require an API key sent via the X-API-Key header.
curl https://megaconvert.io/api/v1/usage \
-H "X-API-Key: mc_your_api_key_here"
Keep your key secret. Never commit it to version control or expose it in client-side code. Use environment variables.
Getting an API Key
- Register for a free account
- Go to Dashboard → API Keys
- Click "Create API Key" — copy it immediately (shown only once)
Rate Limits & Plans
Every response includes rate limit headers:
X-RateLimit-Limit: 10
X-RateLimit-Remaining: 7
| Plan | Price | Requests/day | Max file | Sync |
|---|---|---|---|---|
| Free | $0 | 10 | 25 MB | ✓ |
| Developer | $9/mo | 100 | 100 MB | ✓ |
| Pro | $29/mo | 500 | 500 MB | ✓ |
| Business | $79/mo | 2,000 | 2 GB | ✓ |
Limits reset daily at midnight UTC. Need more? Contact us for enterprise plans.
POST /convert/sync
RECOMMENDEDUpload a file and receive the converted file directly in the response. No polling required. Perfect for scripts, CLI tools, and AI assistants.
| Parameter | Type | Description |
|---|---|---|
file | multipart file | The file to convert *required |
output_format | string | Target format (e.g. pdf, png, mp3) *required |
Response
- 200 — Converted file binary (check
Content-Typeheader) - 202 — Conversion still processing (JSON with
job_idandstatus_urlfor polling) - 422 — Conversion failed (JSON error)
Examples
# Convert Word to PDF
curl -X POST https://megaconvert.io/api/v1/convert/sync \
-H "X-API-Key: YOUR_API_KEY" \
-F "file=@report.docx" \
-F "output_format=pdf" \
-o report.pdf
# Convert PNG to WebP
curl -X POST https://megaconvert.io/api/v1/convert/sync \
-H "X-API-Key: YOUR_API_KEY" \
-F "file=@photo.png" \
-F "output_format=webp" \
-o photo.webp
# Convert video MP4 to MP3 (extract audio)
curl -X POST https://megaconvert.io/api/v1/convert/sync \
-H "X-API-Key: YOUR_API_KEY" \
-F "file=@video.mp4" \
-F "output_format=mp3" \
-o audio.mp3
Timeout: If conversion takes more than 90 seconds, the API returns HTTP 202 with a status_url for async polling. Max sync file size: 100 MB.
POST /convert
Async conversion. Upload a file, get a job ID, then poll for status. Best for large files or batch processing.
curl -X POST https://megaconvert.io/api/v1/convert \
-H "X-API-Key: YOUR_API_KEY" \
-F "file=@large-video.mov" \
-F "output_format=mp4"
Response:
{
"job_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"status": "pending",
"input_format": "mov",
"output_format": "mp4",
"file_size": 52428800,
"status_url": "https://megaconvert.io/api/v1/status/a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"download_url": "https://megaconvert.io/api/v1/download/a1b2c3d4-e5f6-7890-abcd-ef1234567890"
}
POST /tool
Apply a tool to a file (compress, rotate, resize, etc.).
| Parameter | Type | Description |
|---|---|---|
file | multipart file | The file to process |
tool | string | Tool ID (e.g. compress, rotate-pdf) |
quality | string | Optional: high, balanced, maximum |
# Compress a PDF
curl -X POST https://megaconvert.io/api/v1/tool \
-H "X-API-Key: YOUR_API_KEY" \
-F "file=@large.pdf" \
-F "tool=compress" \
-F "quality=balanced"
GET /status/{job_id}
Check the progress of an async conversion job.
curl https://megaconvert.io/api/v1/status/JOB_ID \
-H "X-API-Key: YOUR_API_KEY"
Response when completed:
{
"job_id": "a1b2c3d4-...",
"status": "completed",
"progress": 100,
"output_size": 245760,
"download_url": "https://megaconvert.io/api/v1/download/a1b2c3d4-..."
}
Possible statuses: pending, processing, completed, failed
GET /download/{job_id}
Download the converted file from an async job.
curl https://megaconvert.io/api/v1/download/JOB_ID \
-H "X-API-Key: YOUR_API_KEY" \
-o output.pdf
Files expire after 24 hours.
GET /formats
List all supported conversion pairs. No authentication required.
curl https://megaconvert.io/api/v1/formats
GET /tools
List all available tools (compress, rotate, etc.). No authentication required.
curl https://megaconvert.io/api/v1/tools
GET /usage
Check your current usage and remaining quota.
curl https://megaconvert.io/api/v1/usage \
-H "X-API-Key: YOUR_API_KEY"
{
"plan": "free",
"requests_today": 3,
"rate_limit": 10,
"remaining": 7,
"max_file_size": 26214400,
"max_file_size_human": "25 MB"
}
Use with AI Assistants
MegaConvert works seamlessly with Claude, ChatGPT, and other AI coding assistants. Give them these instructions and they can convert files for you without installing any libraries.
C Claude Code / Claude
Add this to your project's CLAUDE.md or system prompt:
# File Conversion
When you need to convert a file to another format, use the MegaConvert API.
No libraries or tools need to be installed - just use curl.
API Key: YOUR_API_KEY (set as env var MEGACONVERT_API_KEY)
## Convert a file (sync - returns file directly):
```bash
curl -X POST https://megaconvert.io/api/v1/convert/sync \
-H "X-API-Key: $MEGACONVERT_API_KEY" \
-F "file=@INPUT_FILE" \
-F "output_format=TARGET_FORMAT" \
-o OUTPUT_FILE
```
## Common conversions:
- Documents: docx->pdf, pdf->docx, xlsx->csv, pptx->pdf, html->pdf
- Images: png->webp, jpg->png, svg->png, heic->jpg, webp->gif
- Video: mp4->mp3, mov->mp4, avi->mp4, mkv->webm
- Audio: wav->mp3, flac->mp3, m4a->wav, ogg->mp3
## Check available formats:
```bash
curl https://megaconvert.io/api/v1/formats
```
The API handles all conversion server-side. Max 25MB on free tier.
Sync endpoint returns the file directly (no polling needed).
G ChatGPT / GPT-4
For ChatGPT with code interpreter or custom GPTs, add to system instructions:
# File Conversion Tool
To convert files between formats, use the MegaConvert API via curl or Python requests.
This avoids installing heavy libraries like LibreOffice, FFmpeg, or ImageMagick.
## Python example:
```python
import requests
def convert_file(input_path, output_format, output_path, api_key="YOUR_API_KEY"):
"""Convert a file using MegaConvert API."""
with open(input_path, 'rb') as f:
response = requests.post(
'https://megaconvert.io/api/v1/convert/sync',
headers={'X-API-Key': api_key},
files={'file': f},
data={'output_format': output_format}
)
if response.status_code == 200:
with open(output_path, 'wb') as out:
out.write(response.content)
return output_path
else:
raise Exception(f"Conversion failed: {response.json()}")
# Usage:
convert_file('report.docx', 'pdf', 'report.pdf')
convert_file('photo.heic', 'jpg', 'photo.jpg')
convert_file('video.mov', 'mp4', 'video.mp4')
```
## Supported: 500+ format pairs including documents, images, video, audio.
## Free tier: 10 conversions/day, 25MB max. No signup required for /formats endpoint.
* Cursor / Copilot / Any AI IDE
Add to .cursorrules, .github/copilot-instructions.md, or project docs:
# File Conversion
For any file format conversion, use the MegaConvert API instead of installing
local tools. It supports 500+ format pairs via a single curl command.
API: https://megaconvert.io/api/v1/convert/sync
Auth: X-API-Key header
Method: POST multipart/form-data with "file" and "output_format" fields
Response: Binary file (200) or JSON error
Example: curl -X POST https://megaconvert.io/api/v1/convert/sync \
-H "X-API-Key: $MEGACONVERT_API_KEY" -F "file=@input.docx" \
-F "output_format=pdf" -o output.pdf
Docs: https://megaconvert.io/docs/api
Code Examples
#!/bin/bash
# Convert a file with MegaConvert API
API_KEY="${MEGACONVERT_API_KEY:-your_key_here}"
INPUT_FILE="$1"
OUTPUT_FORMAT="$2"
OUTPUT_FILE="${3:-output.$OUTPUT_FORMAT}"
curl -X POST "https://megaconvert.io/api/v1/convert/sync" \
-H "X-API-Key: $API_KEY" \
-F "file=@$INPUT_FILE" \
-F "output_format=$OUTPUT_FORMAT" \
-o "$OUTPUT_FILE"
echo "Converted: $OUTPUT_FILE"
# pip install requests (only dependency)
import requests
import os
API_KEY = os.environ.get('MEGACONVERT_API_KEY', 'your_key_here')
BASE_URL = 'https://megaconvert.io/api/v1'
def convert(input_path: str, output_format: str, output_path: str = None) -> str:
"""Convert a file to another format. Returns output path."""
if not output_path:
base = os.path.splitext(input_path)[0]
output_path = f"{base}.{output_format}"
with open(input_path, 'rb') as f:
resp = requests.post(
f'{BASE_URL}/convert/sync',
headers={'X-API-Key': API_KEY},
files={'file': (os.path.basename(input_path), f)},
data={'output_format': output_format},
stream=True
)
if resp.status_code == 200:
with open(output_path, 'wb') as out:
for chunk in resp.iter_content(8192):
out.write(chunk)
return output_path
elif resp.status_code == 202:
# Still processing - poll status_url
data = resp.json()
print(f"Processing... poll: {data['status_url']}")
return None
else:
raise Exception(f"Error {resp.status_code}: {resp.json()}")
# Usage
convert('document.docx', 'pdf')
convert('photo.heic', 'jpg')
convert('video.mov', 'mp4', 'output.mp4')
// Node.js 18+ (native fetch, no dependencies)
const fs = require('fs');
const path = require('path');
const API_KEY = process.env.MEGACONVERT_API_KEY || 'your_key_here';
const BASE_URL = 'https://megaconvert.io/api/v1';
async function convert(inputPath, outputFormat, outputPath) {
if (!outputPath) {
const base = path.basename(inputPath, path.extname(inputPath));
outputPath = `${base}.${outputFormat}`;
}
const form = new FormData();
form.append('file', new Blob([fs.readFileSync(inputPath)]), path.basename(inputPath));
form.append('output_format', outputFormat);
const resp = await fetch(`${BASE_URL}/convert/sync`, {
method: 'POST',
headers: { 'X-API-Key': API_KEY },
body: form,
});
if (resp.ok) {
const buffer = Buffer.from(await resp.arrayBuffer());
fs.writeFileSync(outputPath, buffer);
return outputPath;
} else {
const err = await resp.json();
throw new Error(`Error ${resp.status}: ${err.error}`);
}
}
// Usage
convert('report.docx', 'pdf').then(console.log);
convert('image.png', 'webp').then(console.log);
<?php
// No dependencies - uses built-in cURL
function megaconvert(string $inputPath, string $outputFormat, string $outputPath = ''): string {
$apiKey = getenv('MEGACONVERT_API_KEY') ?: 'your_key_here';
if (!$outputPath) {
$outputPath = pathinfo($inputPath, PATHINFO_FILENAME) . '.' . $outputFormat;
}
$ch = curl_init('https://megaconvert.io/api/v1/convert/sync');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["X-API-Key: $apiKey"],
CURLOPT_POSTFIELDS => [
'file' => new CURLFile($inputPath),
'output_format' => $outputFormat,
],
]);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($httpCode === 200) {
file_put_contents($outputPath, $response);
return $outputPath;
}
throw new RuntimeException("Conversion failed ($httpCode): $response");
}
// Usage
megaconvert('invoice.docx', 'pdf');
megaconvert('photo.png', 'webp', 'optimized.webp');
Error Codes
| HTTP | Code | Description |
|---|---|---|
| 400 | unsupported | Conversion pair not supported |
| 401 | missing_api_key | No X-API-Key header |
| 401 | invalid_api_key | Key not found or revoked |
| 403 | ip_not_allowed | IP not in whitelist |
| 413 | file_too_large_for_sync | File exceeds plan limit |
| 422 | conversion_failed | Engine could not convert |
| 429 | rate_limit_exceeded | Daily limit reached |
All errors return JSON: {"error": "...", "code": "..."}
Changelog
/convert/sync) — get converted files in a single request
/formats and /tools endpoints are now public (no auth needed)