Two uses: (1) [た-form] + ことがある = have the experience of doing something; (2) [dictionary form] + ことがある = it sometimes happens.
[Verb た-form] + ことがある (experience) | [Dict form] + ことがある (sometimes)
富士山に登ったことがあります。
Fujisan ni nobotta koto ga arimasu.
I have climbed Mt. Fuji (before).
登った (past) + ことがある = have the experience
仕事で遅くなることがある。
Shigoto de osoku naru koto ga aru.
Sometimes I'm late because of work.
dictionary form 遅くなる + ことがある = it sometimes happens
一度もその映画を見たことがない。
Ichido mo sono eiga wo mita koto ga nai.
I have never seen that movie even once.
見た + ことがない = have never (experience negation)
• たことがある (Have you ever...?) is one of the most essential N4 patterns. • たことがない = have never. • Typical answers: はい、〜たことがあります / いいえ、〜たことがありません. • Distinguish from dictionary-form + ことがある = 'it sometimes happens' (frequency).
The JLPT rarely asks whether you recognise a pattern — it asks which of several similar patterns fits. These are the ones ことがある is tested against.
With た-form it means past EXPERIENCE ('have done'); with dictionary form it means OCCASIONAL occurrence ('sometimes happens').
The negative of the experience use — 'have never done', not 'never happens'.
Study Japanese grammar on LenGaki

Get the Android app
The app adds offline study, home-screen widgets, stroke-order tracing, speaking practice with pronunciation scoring, and an AI tutor that answers questions in context — none of which fits in a browser tab.