DevToolsmith

ICS MIME Type

text/calendar is the MIME type for iCalendar events and calendars (.ics). Here is the Content-Type header to send, the file signature, and how to configure servers and code.

MIME type
text/calendar
Extensions
.ics, .ifb
Content-Type header
text/calendar; charset=utf-8
Registered
Yes, with IANA
Compress with gzip
Yes, it is text or uncompressed
Category
Data and text

About iCalendar files

Used for “Add to calendar” links and calendar subscriptions. With the right type, phones and desktop mail apps offer to add the event; a calendar feed that should stay in sync is linked with webcal:// instead of https://. Lines must end in CRLF, and long lines are folded at 75 bytes.

File signature

ICS files start with "BEGIN:VCALENDAR". 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 .ics with the right Content-Type

Response header
Content-Type: text/calendar; charset=utf-8
nginx (a line in the types { } block of mime.types)
text/calendar ics ifb;
Apache (.htaccess or server config)
AddType text/calendar .ics .ifb
AddCharset UTF-8 .ics .ifb
Caddy
@ics path *.ics *.ifb
header @ics Content-Type "text/calendar; charset=utf-8"
Check what a server sends
curl -sI https://example.com/file.ics | grep -i '^content-type'
# Content-Type: text/calendar; charset=utf-8

Set the type in code

Node.js (Express)
res.set('Content-Type', 'text/calendar; charset=utf-8');
Python
import mimetypes

mimetypes.add_type('text/calendar', '.ics')  # if your system doesn't know it
mimetypes.guess_type('file.ics')[0]  # 'text/calendar'
Go
mime.AddExtensionType(".ics", "text/calendar; charset=utf-8")
w.Header().Set("Content-Type", "text/calendar; charset=utf-8")

Accept .ics uploads

HTML
<input type="file" accept=".ics,.ifb,text/calendar">

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

  • .txt (text/plain): Plain text
  • .csv (text/csv): CSV
  • .json (application/json): JSON

More data and text

.tsv , .md , .ndjson , .jsonld , .xml , .yaml , .geojson , .sql . 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 .ics files?

text/calendar. It is a text format, so add the character set: "Content-Type: text/calendar; charset=utf-8".

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

Web servers pick the type from the file extension using a table (mime.types in nginx and Apache). If .ics 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 ICS?

Look at the first bytes rather than the extension or the type the browser reports, which both come from the file name. ICS files start with "BEGIN:VCALENDAR". The MIME type lookup on this site reads them for you when you drop a file on it.