We all know the feeling. You hear a song on the radio, in a shop or in a video. Maybe you haven’t heard it in years. A few hours later, you suddenly notice yourself humming the same melody. And no matter what you do, you just can’t get it out of your head. You weren’t even trying to remember the song. You might not even like it. Yet somehow, your brain has decided to put it on repeat all day.
This phenomenon is known as an earworm: a piece of music that spontaneously pops into your head without you consciously trying to think about it. It may seem like a small and harmless occurrence, but an earworm is a great example of how different cognitive processes work together.
Music and Cognition
Cognition is about how we process information: how we perceive the world around us, remember information, direct our attention, make decisions and form predictions. Music constantly gives our brain material to work with. A song consists of repeating rhythms, melodies and patterns. While listening, your brain does not just process what is happening now; it also tries to predict what comes next. Much of this happens automatically and subconsciously.
As a melody repeats, the pattern becomes increasingly familiar. Your brain needs less effort to recognise it and can more easily predict what comes next. This is an important part of how we experience music, but it may also help explain why a song can so easily pop back into your head.
What Happens When a Song Gets Stuck in Your Head?
An earworm is essentially a musical memory that becomes active again. You are not hearing actual music, but because your brain has formed a pattern through repeated exposure to a song, it can replay a fragment of the melody or lyrics internally.
Working memory plays an important role in this process. You can think of working memory as a kind of mental notepad: a system that temporarily keeps information active while you work with it.
Imagine that you play the opening lines of a chorus in your head. Your working memory helps keep that information temporarily active, allowing you to repeat or continue the fragment. This does not have to happen consciously. You do not need to remember the entire song. Often, a small fragment is enough. A short melody or just a few words can be sufficient to reactivate the musical pattern.
But an earworm does not rely on working memory alone. The fragment usually comes from your long-term memory, where previous experiences with the song have been stored. Your brain retrieves this information and temporarily keeps part of it active. You could think of it as a cognitive loop: a familiar memory is activated, your working memory holds the fragment for a while, and your brain activates it again.
Why Does It Sometimes Come Out of Nowhere?
You’re working, walking to the supermarket or standing in the shower, and suddenly a song pops into your head. It feels random, but sometimes the trigger is something you barely even notice.
Your brain constantly makes connections between what you experience and information stored in your memory. For example, seeing a bicycle might subconsciously remind you of a song that mentions one. You might not consciously think about the connection, but the sight of the bicycle can activate an associated memory, bringing the melody or lyrics into your mind. The same can happen with a word, a sound, a place or even a particular feeling.
These associations can activate a musical memory without you deliberately trying to recall the song. By the time you notice yourself humming it, the process may already have started. That is why an earworm can seem to come out of nowhere, even when something in your surroundings may have triggered it.
Why Does That Particular Song Get Stuck?
So why do some songs get stuck in your head while others disappear as soon as they stop playing? As discussed earlier, familiarity and musical patterns help your brain recognise and predict what comes next. But other factors also influence which songs return to your thoughts.
Research suggests that earworms are often associated with songs that have distinctive melodies or unexpected musical elements that make them memorable. Your personal experiences matter, too. A song linked to a particular memory, place or moment in your life may be more likely to come back to mind. Sometimes, even a small reminder, such as a word, a sound or a familiar situation, can bring the melody back.
In other words, an earworm is not just about the song itself, but also about the connections your brain has formed between music, memories and your surroundings.
The Cognitive Loop
But why does the song keep repeating itself? This has to do with a kind of cognitive loop. Once the musical memory has been activated, your brain can replay the melody in your mind. This is known as auditory imagery: the ability to experience sounds without them actually being present. The fragment returns to your thoughts and can then be repeated, making it feel as though your brain has put the song on repeat.
Working memory may play a role here. You can think of it as a mental notepad that temporarily keeps information active. It can help you hold on to a piece of melody while repeating it in your mind. At the same time, your brain can retrieve the fragment from long-term memory again and again. The song does not necessarily remain in your working memory continuously; it may be reactivated repeatedly.
Your own reaction can also keep the loop going. The more you try to get a song out of your head, the more often you may check whether you are still thinking about it. This brings the song back to your attention and can make the melody return.
Why some earworms are so persistent while others quickly disappear is not yet fully understood. Several processes involving memory, repetition and attention are likely to work together. However, the idea of a loop helps explain why a short musical fragment can keep resurfacing: your brain retrieves it, plays it internally and can then activate it all over again.
How Can You Get Rid of an Earworm?
Some people try listening to the entire song from beginning to end. Others deliberately put on different music or focus their attention on a task that requires more cognitive effort. Attention plays a role here, too. When you become fully absorbed in another activity, there is simply less room to keep focusing on the same musical fragment. This illustrates how our cognitive capacity is limited and how we constantly have to determine which information to keep active.



