MOBI to WebP API
POST a .mobi file to /v2/convert/mobi/to/webp and get a lossless WebP for each page. The sample asks for PageRange=4-5 and gets two chapters of the lighthouse book, with its bar chart and map, as 1275 × 1650 images of 114,586 and 131,972 bytes.
- Endpoint
- POST /v2/
convert/ mobi/ to/ webp - Accepts
- mobi
- Sample timing
- 52 ms median of 5 runsHow we measure
- Request size
- Up to 10 MB on the Free plan or 100 MB on paid plans, all files together
Request and response
Every sample below ran against the API before this page was published. Set PDFCONVERSIONAPI_KEY to your key and run it as is.
curl -sS -X POST \
https://api.pdfconversionapi.com/v2/convert/mobi/to/webp \
-H "Authorization: Bearer $PDFCONVERSIONAPI_KEY" \
-F File=@cape-merrow-light.mobi \
--form-string PageRange=4-5 \
-o response.json
# FileData is base64. Save the first file in converted/,
# or print the JSON error.
if jq -e '.Files' response.json > /dev/null; then
mkdir -p converted
name=$(jq -r '.Files[0].FileName' response.json)
jq -r '.Files[0].FileData' response.json \
| base64 --decode > "converted/$name"
else
cat response.json
fiimport base64
import os
import requests
key = os.environ["PDFCONVERSIONAPI_KEY"]
response = requests.post(
"https://api.pdfconversionapi.com/v2/convert/mobi/to/webp",
headers={"Authorization": f"Bearer {key}"},
files=[("File", open("cape-merrow-light.mobi", "rb"))],
data={
"PageRange": "4-5",
},
timeout=180,
)
result = response.json()
if not response.ok:
raise SystemExit(f"{result['Code']}: {result['Message']}")
os.makedirs("converted", exist_ok=True)
for file in result["Files"]:
path = os.path.join("converted", file["FileName"])
with open(path, "wb") as out:
out.write(base64.b64decode(file["FileData"]))
print(path, file["FileSize"], "bytes")
import { mkdir, readFile, writeFile } from "node:fs/promises";
import { join } from "node:path";
const form = new FormData();
const file = "cape-merrow-light.mobi";
form.append("File", new Blob([await readFile(file)]), file);
form.append("PageRange", "4-5");
const url = "https://api.pdfconversionapi.com/v2/convert/mobi/to/webp";
const key = process.env.PDFCONVERSIONAPI_KEY;
const response = await fetch(url, {
method: "POST",
headers: { Authorization: `Bearer ${key}` },
body: form,
});
const result = await response.json();
if (!response.ok) {
throw new Error(`${result.Code}: ${result.Message}`);
}
await mkdir("converted", { recursive: true });
for (const file of result.Files) {
const path = join("converted", file.FileName);
await writeFile(path, Buffer.from(file.FileData, "base64"));
console.log(path, file.FileSize, "bytes");
}
{
"ConversionCost": 1,
"ConversionTime": 0.052,
"Files": [
{
"FileName": "cape-merrow-light-4.webp",
"FileExt": "webp",
"FileSize": 114586,
"FileData": "UklGRpK/AQBXRUJQVlA4TIW/…"
},
{
"FileName": "cape-merrow-light-5.webp",
"FileExt": "webp",
"FileSize": 131972,
"FileData": "UklGRnwDAgBXRUJQVlA4THAD…"
}
]
}Response from our test run on 2026-11-03. ConversionTime shows the median of 5 runs. FileData is shortened here; the real response carries the whole file as base64.
The sample, converted
The same file the code sends. Download the input and the output and compare them yourself.

- Input
- cape-merrow-light.mobi (29 KB)
- Output
- cape-merrow-light-4.webp (112 KB)cape-merrow-light-5.webp (129 KB)
- Source
- A short fictional e-book about a lighthouse keeper's year, with a cover, a map and a chart, written and drawn by us and packed as a MOBI file by our own script. (CC0-1.0). How it was made
- Made by
- 2026-11-04, API build
9eeeb0640aba
Parameters
Send these as form fields next to the file. Names are case-insensitive. If you set one of the documented options below that we don't support yet, the request fails with a 400 that names it instead of returning a file made without it.
| Parameter | What it does |
|---|---|
PageRangestring | Pages to render. In the sample, page 4 is chapter 2 with the GIF chart and page 5 is chapter 3 with the PNG map; the files keep those numbers (-4.webp, -5.webp).Values: 1, 4-5, 3-, 2-last |
ImageResolutioninteger, default 150 | Pixels per inch of the page; at 150 a Letter page is 1275 × 1650. WebP stores no resolution.Values: 36–600 |
ImageWidthinteger | Fixed width per page in pixels, for a reader column.Values: 1–20,000 |
ImageHeightinteger | Fixed height per page in pixels.Values: 1–20,000 |
PageSizeenum, default letter | Page format; a6 gives the sample 13 phone-shaped pages.Values: a0–a9, b0–b5, letter, legal, ledger |
BaseFontSizenumber, default 12 | Body size in points; headings follow, since the book brings no CSS.Values: 1–50 (points) |
MarginTopnumber, default 40 | Top margin in points.Values: 0–200 (points) |
MarginRightnumber, default 40 | Right margin in points.Values: 0–200 (points) |
MarginBottomnumber, default 40 | Bottom margin in points.Values: 0–200 (points) |
MarginLeftnumber, default 40 | Left margin in points.Values: 0–200 (points) |
TransparentColorstring | Turns an exact color, usually white, transparent.Values: Color names, #RRGGBB or R,G,B |
BackgroundColorstring, default white | Page color under the text.Values: Color names, #RRGGBB or R,G,B |
ColorSpaceenum, default default | Gray or black-and-white pixel values in an RGB WebP.Values: default, rgb, gray, monochrome |
FileNamestring | Stem for the file names. |
StoreFileboolean, default false | Links for 3 hours in place of base64. |
Not supported yet
Setting one of these to anything but its default returns 400.
| Option | What to do instead |
|---|---|
ImageQuality | WebP is written lossless. ConvertAPI's default 75 is accepted; other values return 400 "ImageQuality is not supported yet for MOBI → WebP". |
What carries over, and what doesn't
Kept
- Exact pixels: VP8L lossless WebP, with the GIF chart's bars and the map's labels as sharp as in the book
- The chapter headings, the italic captions under both pictures, and the bullet list on page 5
- The page numbering of the full book in the file names, even when only some pages are requested
- Opaque RGB pixels; an alpha channel is written only when
TransparentColoris set
Lost or not yet supported
- A lossy mode for smaller files; lower
ImageResolutionor usemobi/to/jpginstead. - The centering MOBI books set with align attributes: the sample's chart, map and captions sit at the left margin.
- Table borders and font size attributes, which our layout does not draw.
- Links from the book's contents page and selectable text.
- The book's metadata, which is not carried into the image files.
Limits
- One book per request.
- Requests up to 10 MB on the Free plan or 100 MB on paid plans, all files and fields together.
- Up to 2,000 pages per request; drawn pages may be at most 16,000 px a side and 100,000,000 pixels.
- DRM-protected books return 422; HUFF/CDIC compression returns 404.
- A
PageRangepast the last page returns 400 naming the page count. - 120 seconds per conversion.
Where teams use it
Reading old MOBI titles in the browser
Render a book's pages as WebP once and serve them from your own storage to a simple page viewer. Readers need no Kindle app, and the images keep the book's pictures.
Chapter samples for a catalog
Pick a chapter with PageRange and show its pages on the book's listing. The sample's two chapter pages total 246,558 bytes as lossless WebP.
Questions
Why can't I choose a WebP quality?
Pages are encoded as lossless WebP, so there is no quality to choose. ImageQuality=75 is accepted for compatibility with ConvertAPI's default; other values return 400 rather than being ignored.
How does WebP compare with PNG for book pages?
For the sample at 150 dpi, page 4 was 114,586 bytes as WebP and 304,496 bytes as PNG, and page 5 was 131,972 against 339,232. Both are lossless, so the pixels are the same.
Will a large picture be cut off?
It can be. Pictures are drawn at their stored pixel size, three quarters of a point per pixel, and are not scaled to fit: a 1,400-pixel-wide test picture in place of the sample's map was cut off at the right margin. The sample's own pictures fit on Letter, though on A5 the 360 × 540 cover pushes the publisher's name to page 2.
Convert your first MOBI file in a minute.