Base64 Files
Reference

Base64 MIME Types

Look up any file extension's MIME type and copy its Data URI prefix. Covers images, documents, fonts, audio, video, and 37 common formats.

Showing 37 of 37

ExtensionMIME TypeData URI PrefixDescriptionCopy
.pngimage/pngdata:image/png;base64,PNG raster image, supports transparency
.jpgimage/jpegdata:image/jpeg;base64,JPEG photo, high compression
.jpegimage/jpegdata:image/jpeg;base64,JPEG photo, same as .jpg
.webpimage/webpdata:image/webp;base64,WebP modern format, smaller than PNG/JPEG
.gifimage/gifdata:image/gif;base64,GIF animated image
.svgimage/svg+xmldata:image/svg+xml;base64,SVG vector image, can be embedded directly in HTML
.icoimage/x-icondata:image/x-icon;base64,ICO icon, used for favicon
.avifimage/avifdata:image/avif;base64,AVIF ultra-high compression format
.bmpimage/bmpdata:image/bmp;base64,BMP bitmap, uncompressed
.tiffimage/tiffdata:image/tiff;base64,TIFF high-precision image
.pdfapplication/pdfdata:application/pdf;base64,PDF document, for API transmission or inline embedding
.docapplication/msworddata:application/msword;base64,Word document (legacy format)
.docxapplication/vnd.openxmlformats-officedocument.wordprocessingml.documentdata:application/vnd.openxmlformats-of…Word document (modern format)
.xlsapplication/vnd.ms-exceldata:application/vnd.ms-excel;base64,Excel spreadsheet (legacy format)
.xlsxapplication/vnd.openxmlformats-officedocument.spreadsheetml.sheetdata:application/vnd.openxmlformats-of…Excel spreadsheet (modern format)
.zipapplication/zipdata:application/zip;base64,ZIP archive
.txttext/plaindata:text/plain;base64,Plain text
.htmltext/htmldata:text/html;base64,HTML page, can be used as iframe src
.csstext/cssdata:text/css;base64,CSS stylesheet
.jstext/javascriptdata:text/javascript;base64,JavaScript script
.jsonapplication/jsondata:application/json;base64,JSON data, API payload
.xmlapplication/xmldata:application/xml;base64,XML data
.csvtext/csvdata:text/csv;base64,CSV tabular data
.mdtext/markdowndata:text/markdown;base64,Markdown document
.wofffont/woffdata:font/woff;base64,WOFF web font, CSS @font-face
.woff2font/woff2data:font/woff2;base64,WOFF2 better compression, recommended
.ttffont/ttfdata:font/ttf;base64,TrueType font
.otffont/otfdata:font/otf;base64,OpenType font
.mp3audio/mpegdata:audio/mpeg;base64,MP3 audio
.wavaudio/wavdata:audio/wav;base64,WAV lossless audio
.oggaudio/oggdata:audio/ogg;base64,OGG audio
.aacaudio/aacdata:audio/aac;base64,AAC audio
.flacaudio/flacdata:audio/flac;base64,FLAC lossless audio
.mp4video/mp4data:video/mp4;base64,MP4 video
.webmvideo/webmdata:video/webm;base64,WebM video
.ogvvideo/oggdata:video/ogg;base64,OGG video
.movvideo/quicktimedata:video/quicktime;base64,QuickTime video

What is a MIME Type?

MIME Type (Multipurpose Internet Mail Extensions) is a standard content identifier that describes the format of a file or data. The format is type/subtype, for example:

image/png

PNG image

application/pdf

PDF document

font/woff2

WOFF2 font

application/json

JSON data

Browsers and servers use MIME types to determine how to handle content — display images, render HTML, trigger a download, or play video.

Why the MIME type matters in Base64

In a Data URI, the MIME type tells the browser how to interpret the Base64 data. The format is:

data:image/png;base64,iVBORw0KGgo…

If the MIME type is wrong:

The correct MIME type ensures the browser renders Base64 data correctly — whether in <img src="data:...">, background-image: url("data:...") or any API payload.

How to choose the right MIME type

1

Known file extension

Look up the table above. Most common formats have a standard MIME type — just copy it.

2

Reading files in the browser

Use the File object's type property: const mime = file.type. Browsers detect MIME types automatically, but may return an empty string for uncommon formats.

3

Server-side detection

Don't rely solely on the file extension. Use a library (e.g. file-type for Node.js, python-magic for Python) to inspect file headers (magic bytes) for a more reliable result.

4

Unknown file type

Use application/octet-stream — the generic binary type. Browsers typically prompt a download rather than trying to render it.

Related Tools

Frequently Asked Questions

What is a MIME type?

A MIME type is a standard content format identifier in the form type/subtype (e.g. image/png). Browsers and servers use it to determine how to handle received content — display an image, render a web page, play video, or trigger a download.

Why can't the MIME type in a Data URI be wrong?

The MIME type tells the browser what the Base64 data contains. A wrong MIME type can prevent images from rendering, fonts from loading, or JSON from being parsed correctly. For example, using image/jpeg instead of image/png may cause some browsers to refuse to render the image.

What is the Data URI prefix format?

The format is data:[mime-type];base64,. For a PNG image the prefix is data:image/png;base64,. Prepend this to a Base64 string to create a complete Data URI, usable anywhere a URL is accepted.

What MIME type should I use for an unknown file?

Use application/octet-stream — the generic binary type. Browsers typically prompt a file download when they encounter this type rather than trying to render it, making it a safe default for unknown formats.

What is the MIME type for SVG?

image/svg+xml. Note the +xml suffix — it is not simply image/svg. In a Data URI it is data:image/svg+xml;base64,....

What MIME types are used for font files?

WOFF2 uses font/woff2, WOFF uses font/woff, TTF uses font/ttf, and OTF uses font/otf. These are the standard font MIME types defined in RFC 8081, used in CSS @font-face Data URI embedding.