What File Formats are Supported by the Cloudinary API?
Cloudinary supports many file formats, including common image formats like JPEG, PNG, GIF, BMP, WebP, AVIF, and SVG.
For videos, it supports MP4, WebM, MOV, AVI, and FLV. Audio formats include MP3, OGG, and WAV. Additionally, Cloudinary can handle raw files such as PDFs, ZIP files, DOCX, and PSDs.
{{cool-component}}
Here’s what this mumbo-jumbo means for you:
Image Formats
Images are probably the most common type of media you'll upload. Cloudinary supports JPEG, PNG, GIF, BMP, and TIFF.
The f_auto feature in the Cloudinary API allows you to automatically serve the most optimal format for the user's browser. So, for instance, if someone’s browser supports WebP, Cloudinary will automatically serve that version instead of JPEG. It's a neat trick that saves you a lot of time in optimizing images:
There’s a slight catch with SVGs. You can convert them to other formats, but serving them directly requires a bit of additional work to ensure the file is sanitized for security purposes.
Video Formats
Now, let's talk about videos. Cloudinary supports all the major formats you'd expect: MP4, WebM, MOV, AVI, and FLV.
Cloudinary's API lets you convert videos between formats if needed. You can trim, resize, and even overlay text or images on videos—all through the API.
Audio Formats
Cloudinary supports MP3, OGG, and WAV for audio files. I haven't used Cloudinary for audio as much, but it works well if you need to manage and deliver audio assets.
You can transform these files similarly to images and videos, although the transformations are more limited to basic tasks like trimming.
Raw File Formats
Now, beyond media, Cloudinary handles what they call raw files—essentially anything that’s not an image or video. This includes formats like PDF, ZIP, DOCX, PSD, and more.
For example, you can upload a PDF and either deliver it directly or create a thumbnail preview:
For free accounts, some raw formats like ZIP and PDF are blocked from public delivery unless you enable specific settings in your Cloudinary dashboard.
Once you enable these, or if you’re on a paid plan, you’re good to go.
Cloudinary Tutorial: Uploading and Transforming
Let’s say you want to upload an image. Using Cloudinary’s API, the basic format looks like this:
uploader.upload("image.jpg", allowed_formats=['jpg', 'png', 'webp'])
You can restrict uploads to certain formats using the allowed_formats parameter, as shown above. If the user uploads an unsupported file format, Cloudinary will reject it unless you tell it to convert on the fly.
For videos, you can specify the same kind of transformations:
uploader.upload("video.mov", resource_type = "video")
By setting the resource_type as video, Cloudinary will handle the file appropriately, allowing you to later transform or convert it into something like MP4.
{{cool-component}}
File Restrictions and Format Conversions
Cloudinary gives you control over which file formats can be uploaded by using the allowed_formats parameter in the API. For example, if you only want to allow PNG uploads, you can enforce that by configuring the API or an upload preset.
On top of that, if a user uploads a file in the wrong format, Cloudinary can automatically convert it to the allowed format before completing the upload.
Here's an example in Python where you restrict uploads to PNG files only:
uploader.upload("image.jpg", allowed_formats=['png'], format='png')
In this case, Cloudinary converts any non-PNG file to PNG before storing it.