Mermaid Timeline Syntax & Examples
Reference for Mermaid timeline syntax — timeline keyword, title, sections, period headings, and event lines. Copy-paste examples for launch recaps, project history, and release notes.
Syntax reference, layout guidance, and ready-to-open examples for this diagram type.
A syntax reference for Mermaid's `timeline` grammar — read this when you need the exact format for sections, period headings, or multi-line events, then try the result in the editor.
View Mermaid sourcePlain-text diagram syntax — copy or edit directly.
1timeline2 title Product launch year3 section Q14 Private alpha5 : Initial design reviews6 : First internal demo7 section Q28 Closed beta9 : Invite-only signup10 : First paid customer11 section Q312 Public beta13 : Marketing site live14 : Feedback sprint15 section Q416 GA launch17 : Pricing finalised18 : Partner integrationsWhat is a Mermaid timeline
A timeline visualises events in chronological order along a single track. It is the right shape when the story is chronology-first: product launch recaps, project history, incident retrospectives, release notes, company milestones. Timelines read top-to-bottom in one pass, with periods grouping events into meaningful chunks (quarters, releases, phases). Use a Gantt chart instead when parallel work streams matter (timelines have one track, no swimlanes), or a flowchart when the events are decision-driven rather than time-driven. Timelines are simpler than both — they're for stories where the only structure is what-happened-when.
Basic syntax — timeline + title + sections
Every Mermaid timeline starts with the `timeline` keyword. Add a title on the next line with `title <Text>`. Then declare sections with `section <Period Name>` — each section groups events under a period heading. Events under a section are listed as bullet-style lines: `Period Label` followed by colon-prefixed `: event description` lines. Sections render as horizontal bands with the section label on the left, and events flow vertically under each section in source order. Mermaid auto-handles colour rotation across sections so each period reads distinctly.
- `timeline` — diagram type keyword (always first)
- `title <Text>` — chart title (appears at the top)
- `section <Period Name>` — period grouping (Q1, Phase 1, etc.)
- Events are bullet-formatted lines under each section
Event format — period heading + detail bullets
Inside a section, an event has two parts. The first line is the period label or main event name: `Public beta`. Following lines starting with `:` are detail bullets attached to that event: `: Marketing site live`, `: Feedback sprint`. The colon-prefixed bullets render under the main event heading. This format lets each event tell a small story — the period label is the headline, the bullets are the supporting details. You can have multiple events per section, each with its own bullets, by repeating the pattern.
Without sections — flat chronology
Sections are optional. If your timeline is short or doesn't have natural period groupings, list events directly under the title without any `section` declarations. The events still render in source order but without the horizontal banding. This is appropriate for short timelines (5-8 events) where every event is roughly equal weight. Once a timeline gets longer or has natural chunks (quarters, phases, releases), sections make it much more scannable — readers can jump to the section that interests them rather than reading top-to-bottom.
When to pick a different chart
Timelines are deliberately minimal — no swimlanes, no dependencies, no parallel tracks. When the content needs those features, pick a different diagram type. Gantt chart: parallel work streams (multiple teams or phases running concurrently), task dependencies ("X starts after Y finishes"), specific date math (durations in days/weeks). Git graph: branching workflows where things diverge and merge. Flowchart: decision-driven processes where the order depends on outcomes. Pick timeline only when the story is genuinely a single linear chronology — even one parallel branch makes a Gantt chart a better fit.
Common patterns & gotchas
Three patterns cover most real timelines. Product launch year (Q1 alpha / Q2 beta / Q3 public beta / Q4 GA) is the most common — sections per quarter, 2-3 events per quarter. Incident retrospective (Detection / Triage / Recovery / Postmortem) is the second — sections per phase, events showing what happened in each phase. Company milestones (Founded / First customer / Series A / IPO) is the third — usually no sections, just a flat list of significant events. The most common gotcha: forgetting that event detail bullets must start with `:` — without the colon, the line becomes a separate event rather than a detail of the previous one. Second gotcha: trying to use a timeline for a roadmap with parallel work — switch to Gantt before you fight the syntax.
- Detail bullets must start with `:` — otherwise they parse as new events
- 6-8 events per section is the readability sweet spot
- For parallel work streams or task dependencies, use Gantt instead