DWG to WebP API
POST a DWG to /v2/convert/dwg/to/webp and receive a lossless WebP of model space, 2400 × 1600, on the same dark background as the PNG route. For the sample deck plan it is 85,052 bytes, against 97,617 for the PNG.
- Endpoint
- POST /v2/
convert/ dwg/ to/ webp - Accepts
- dwg
- Sample timing
- 0.104 s 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/dwg/to/webp \
-H "Authorization: Bearer $PDFCONVERSIONAPI_KEY" \
-F File=@deck-framing-plan.dwg \
-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/dwg/to/webp",
headers={"Authorization": f"Bearer {key}"},
files=[("File", open("deck-framing-plan.dwg", "rb"))],
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 = "deck-framing-plan.dwg";
form.append("File", new Blob([await readFile(file)]), file);
const url = "https://api.pdfconversionapi.com/v2/convert/dwg/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.104,
"Files": [
{
"FileName": "deck-framing-plan.webp",
"FileExt": "webp",
"FileSize": 85052,
"FileData": "UklGRjRMAQBXRUJQVlA4TCdM…"
}
]
}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
- deck-framing-plan.dwg (12 KB)
- Output
- deck-framing-plan.webp (83 KB)
- Source
- A framing plan for a fictional 16 by 12 foot backyard deck, which we drew as a DXF with a short script and saved as DWG (2004 format) (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 |
|---|---|
TransparentColorstring | Makes one exact color transparent. Send the background color, 33,40,48 or #212830, and only the linework stays opaque: 91,678 bytes for the sample.Values: A color name, #RRGGBB or R,G,B |
ColorSpaceenum, default default | gray or monochrome change the pixels, but a WebP can't hold a gray-only image, so the file is still RGB: gray shrinks the sample to 45,314 bytes and monochrome to 14,218. cmyk returns 400.Values: default, rgb, truecolors, gray, grayscale, monochrome |
ImageResolutioninteger | Checked (10–800) and accepted, but WebP has no field for it, so the file doesn't change.Values: 10–800 |
FileNamestring | Output name without .webp; otherwise the DWG's name is used. |
StoreFileboolean, default false | Get a link to the stored WebP, good for 3 hours, instead of the bytes. |
Not supported yet
Setting one of these to anything but its default returns 400.
| Option | What to do instead |
|---|---|
ImageQuality | The WebP is always lossless. Only 75, ConvertAPI's default, is accepted, and it doesn't change the file. |
ImageAntialiasing | Only the default, 8, is accepted. |
SpaceToConvert | Model space only; non-default values return 400. |
ExportLayers | false returns 400. |
Also refused when set: CustomSpaceToConvert.
What carries over, and what doesn't
Kept
- Every pixel of the CAD-screen picture: the WebP is lossless (VP8L), so it decodes to the same image as the PNG
- Layer colors and white color-7 lines on the dark background
- Transparency only on request: the default file is RGB with no alpha channel, and
TransparentColoradds one - Dashed HIDDEN lines, hatching, block inserts with attributes, and the off S-DECKING layer left out as in the file
Lost or not yet supported
- No lossy setting:
ImageQualityother than 75 returns 400, so you can't trade quality for a smaller file. ImageWidthandImageHeightare ignored without an error on this route, and the WebP is still 2400 × 1600. Resize with/v2/convert/webp/to/webpif you need another size.- With
TransparentColor, antialiased line edges keep a dark fringe, because only pixels of exactly the background color become transparent. - No drawing scale, no DPI, and nothing from paper-space layouts.
Limits
- DWG files saved in the R13 through 2018 formats.
- One 2400 × 1600 WebP per DWG.
- A damaged DWG returns 422 with the reader's message.
- Requests up to 10 MB on the Free plan or 100 MB on paid plans, all files and fields together.
- 120 seconds per conversion, then 504.
Where teams use it
Lighter previews on a web page
Serve the WebP instead of the PNG in a drawing viewer or a project portal. It is the same pixels, 13% smaller for the sample, and every current browser displays WebP.
Overlays with a transparent background
With TransparentColor=33,40,48 the drawing's lines float over whatever is behind them, for example a site photo or a map tile. Pick a dark backdrop if the drawing has white color-7 lines.
Questions
Is the WebP lossy or lossless?
Lossless. The file uses the VP8L format, so its pixels match the PNG route exactly; that is also why ImageQuality can't be changed.
How do I get a transparent background?
Send TransparentColor=33,40,48 (or #212830). In the sample, 3,742,112 background pixels become transparent and the lines stay. White color-7 lines then need a dark page behind them to be seen.
Why doesn't `ImageWidth` change anything?
ConvertAPI documents no size options for DWG to WebP, and the API ignores options that aren't documented for a pair, so the request succeeds at 2400 × 1600. On dwg/to/png and dwg/to/jpg the same option returns 400 instead.
Convert your first DWG file in a minute.