DevToolsmith

RAR MIME Type

application/vnd.rar is the MIME type for RAR archives. Here is the Content-Type header to send, the file signature, and how to configure servers and code.

MIME type
application/vnd.rar
Extensions
.rar
Content-Type header
application/vnd.rar
Registered
Yes, with IANA
Compress with gzip
No, it is already compressed
Category
Archives

About RAR archive files

application/vnd.rar is the registered type; application/x-rar-compressed is older and still common. RAR is a proprietary format, so prefer ZIP or 7z for files you distribute.

Other types seen for these files: application/x-rar-compressed , application/x-rar . Accept them when reading uploads, but send application/vnd.rar yourself.

File signature

RAR files start with 52 61 72 21 1A 07 ("Rar!"). The extension and the type a browser reports for an upload both come from the file name, so check these bytes on the server before trusting a file.

Serve .rar with the right Content-Type

Response header
Content-Type: application/vnd.rar
nginx (a line in the types { } block of mime.types)
application/vnd.rar rar;
Apache (.htaccess or server config)
AddType application/vnd.rar .rar
Caddy
@rar path *.rar
header @rar Content-Type "application/vnd.rar"
Check what a server sends
curl -sI https://example.com/file.rar | grep -i '^content-type'
# Content-Type: application/vnd.rar

Set the type in code

Node.js (Express)
res.set('Content-Type', 'application/vnd.rar');
// Or make the browser download it:
res.attachment('file.rar');
Python
import mimetypes

mimetypes.add_type('application/vnd.rar', '.rar')  # if your system doesn't know it
mimetypes.guess_type('file.rar')[0]  # 'application/vnd.rar'
Go
mime.AddExtensionType(".rar", "application/vnd.rar")
w.Header().Set("Content-Type", "application/vnd.rar")

Accept .rar uploads

HTML
<input type="file" accept=".rar,application/vnd.rar">

The accept attribute only filters the file picker; users can still choose another file. Listing the extension as well as the type matters, because operating systems don’t always report the type you expect.

Related types

  • .zip (application/zip): ZIP archive
  • .7z (application/x-7z-compressed): 7-Zip archive
  • .gz (application/gzip): Gzip file

More archives

.tar . Look up any extension or type with the MIME type lookup.

Sources

Spotted a mistake? Email hello@devtoolsmith.com and we’ll fix it.

Frequently asked questions

What is the MIME type for .rar files?

application/vnd.rar. You may also see application/x-rar-compressed, application/x-rar, which are older or unofficial; send application/vnd.rar. The full header is "Content-Type: application/vnd.rar".

Why does my server send the wrong Content-Type for .rar?

Web servers pick the type from the file extension using a table (mime.types in nginx and Apache). If .rar is missing from that table, they send a default such as application/octet-stream or text/plain. Add the mapping as shown on this page, then check the response with "curl -sI".

How can I check that a file really is RAR?

Look at the first bytes rather than the extension or the type the browser reports, which both come from the file name. RAR files start with 52 61 72 21 1A 07 ("Rar!"). The MIME type lookup on this site reads them for you when you drop a file on it.