How to generate an iCal (.ics) file for an event
An iCal file (.ics) is a universal calendar event format that any calendar app can import - Google Calendar, Apple Calendar, Outlook, Yahoo, and any iCal-compatible app. Generating one involves creating a text file that follows the iCalendar standard (RFC 5545).
The fastest way: AddEvent
AddEvent generates a valid .ics file for any event you create - no coding required. When someone clicks your Add to Calendar button or link and selects "Apple Calendar" or "Outlook" (desktop), AddEvent serves the .ics file automatically.
To get the .ics file URL directly: create your event in AddEvent, go to Sharing, and look for the direct .ics download link or iCal feed URL.
Generating an .ics file manually
An .ics file is plain text. Here is a minimal valid example:
` BEGIN:VCALENDAR VERSION:2.0 PRODID:-//Your Company//Your App//EN BEGIN:VEVENT UID:unique-event-id@yourdomain.com DTSTAMP:20261001T120000Z DTSTART;TZID=Europe/Copenhagen:20261015T180000 DTEND;TZID=Europe/Copenhagen:20261015T200000 SUMMARY:Your Event Title DESCRIPTION:A brief description of the event. LOCATION:Venue Name, City END:VEVENT END:VCALENDAR `
Key rules:
DTSTARTandDTENDshould use named time zones (TZID) rather than UTC offsets for correct DST handlingUIDmust be globally unique per event- Line length must not exceed 75 octets (fold long lines with a space or tab at the start of the continuation line)
Generating .ics files programmatically
Libraries that handle iCal generation:
- Python:
icalendarpackage - JavaScript/Node:
ical-generator - PHP:
eluceo/ical - Ruby:
icalendargem
Why AddEvent's .ics generation is preferable to DIY
Building .ics generation correctly - including proper timezone handling, recurring event RRULE syntax, and cross-app compatibility testing - typically takes a developer several hours. AddEvent generates valid, tested .ics files automatically as part of the Add to Calendar flow, including correct timezone data.