Compression API — Free Tier + Pay-As-You-Go
Compress video, image, PDF, and audio files programmatically. Per-file-type presets and target-size mode.
What it does
The Compression API is a unified endpoint for reducing file sizes across video, image, PDF, and audio formats. The API auto-detects the input file type and applies the right compression pipeline: FFmpeg for video (CRF-based re-encoding, optional two-pass for target bitrate), Sharp for images (quality-based or palette-based with optional dimension scaling), Ghostscript for PDF (downsampling embedded images, font subsetting, removing unused objects), and LAME / Opus for audio (bitrate-based re-encoding). Two modes are supported: `mode=quality` accepts a 1-100 quality dial that maps to format-appropriate parameters, and `mode=target-size` iteratively re-compresses until the output fits a specified byte ceiling (`targetSize=1MB`).
The target-size mode is particularly useful for email attachments (8 MB Gmail limit), Slack uploads, and platform-specific upload caps. PDF compression preserves all text searchability and links — only embedded images and unused font glyphs are stripped. Image compression preserves EXIF and ICC profile by default, with options to strip metadata for additional savings.
Video compression maintains the original codec by default unless you specify a different target codec.
Supported formats
Source formats (20)
- mp4
- mov
- mkv
- webm
- avi
- wmv
- flv
- jpg
- png
- webp
- tiff
- heic
- gif
- mp3
- wav
- flac
- m4a
- aac
- ogg
Target formats (11)
- mp4
- mov
- mkv
- webm
- jpg
- png
- webp
- mp3
- wav
- flac
Quick start
All three SDK languages show the same conversion: a single POST to /v1/convert with your API key in the X-Api-Key header.
curl -X POST https://api.convertintomp4.com/v1/compress \
-H "X-Api-Key: ck_your_api_key" \
-F "file=@input.pdf" \
-F "mode=target-size" \
-F "targetSize=8MB"import { ConvertIntoMP4 } from "@convertintomp4/sdk";
import fs from "node:fs";
const client = new ConvertIntoMP4({ apiKey: process.env.CIM4_API_KEY });
const job = await client.compress({
file: fs.createReadStream("input.pdf"),
mode: "target-size",
targetSize: "8MB",
});
const result = await client.waitForJob(job.id);
console.log("Compressed:", result.outputUrl, result.sizeBytes);from convertintomp4 import Client
client = Client(api_key="ck_your_api_key")
with open("input.pdf", "rb") as f:
job = client.compress(file=f, mode="target_size", target_size="8MB")
result = client.wait_for_job(job.id)
print(f"Compressed: {result.output_url} ({result.size_bytes} bytes)")Features
- Unified endpoint for video, image, PDF, audio
- Auto-detection of input file type
- Quality-based or target-size mode
- Two-pass video encoding for tight size targets
- PDF: image downsampling + font subsetting + dead-object removal
- Image: EXIF preservation, palette mode for graphics
- Audio: format-preserving bitrate reduction
Pricing
From $9.99/mo (Pro) or $24.99/mo (Business) — or pay-as-you-go on the API plan.
Free tier: 5 conversions/day, 100 MB file size, no API key required (IP-gated). Pro $9.99/mo: 100/day (2,000/month), 2 GB files. Business $24.99/mo: 1,000/day (20,000/month), 10 GB files, GPU encoding, dedicated support.
See full pricing breakdown →Built for production
99.9% uptime SLA
Multi-region failover, transparent status page, 60-second response-time guarantee on Business.
Encryption + auto-delete
TLS 1.2+ in transit, AES-256 at rest. Files deleted after 1h / 24h / 7d depending on plan, or instantly via DELETE endpoint. See the security page.
~7s median latency
Most sub-100 MB jobs complete in 6-9 seconds. Webhook-driven async for heavier workloads; waitForJob for synchronous flows.
Frequently Asked Questions
What's the difference between quality mode and target-size mode?
Quality mode is fast and predictable — you pick a 1-100 quality value and the API applies appropriate parameters. Target-size mode is slower (iterative) but guarantees the output fits under a byte ceiling. Use quality for general compression, target-size for hard upload limits.
How much can the API compress a PDF without losing quality?
Typical scanned PDFs compress 50-80% via embedded-image downsampling. Born-digital PDFs (LaTeX, InDesign exports) compress 10-30% by stripping unused font glyphs and dead objects. Text and vector graphics are preserved losslessly — only raster images are downsampled.
Does video compression re-encode or just remux?
Compression always re-encodes — that's how size reduction is achieved. For container changes without size reduction, use the Video Conversion API with `mode=remux`. To preserve maximum quality at smallest size, the API uses two-pass encoding when `mode=target-size` is set.
Is image metadata preserved?
By default yes (EXIF + ICC). Pass `stripMetadata=true` to remove all metadata blocks for an additional 1-5 KB savings — useful for privacy-sensitive workflows where camera-make and GPS coordinates should be scrubbed.
Can the API compress multiple files into one ZIP?
Yes — POST a multipart request with multiple `file` fields. Each file is compressed independently and the outputs are packaged into a single ZIP. Useful for batch-compressing an album of photos or a folder of PDFs.
Related APIs
- Merge APIMerge PDFs, videos, images, and audio files programmatically. Order-preserving, format-aware concatenation.
- Split APISplit PDFs by page range, videos by duration, audio by silence detection via API. Per-output naming and ZIP delivery.
- OCR APIOptical Character Recognition for PDFs and images via API. 100+ languages, searchable PDF output, plain-text extraction.
- Watermark APIAdd text or image watermarks to PDFs, videos, and images via API. Configurable position, opacity, rotation, and tiling.
- File Conversion APIOne unified file conversion API for video, audio, image, document, ebook, archive, and font formats — 255 formats, 2,290+ conversion pairs.
- Convert APIProduction-grade file conversion API with 9 language SDKs, async webhooks, and cloud-to-cloud workflows. Free tier available.
Or browse the full catalogue of 23 API products →
Get an API key
Start integrating the Compression API in five minutes. Read the docs, grab a key, and ship your first conversion before the trial coffee cools.