Leitmotifs

A leitmotif (/ˌlaɪtmoʊˈtiːf/) is a musical "phrase" or melody, re-used in multiple songs to associate a tune with a person, event, or place. The extensive use of leitmotifs in Undertale's soundtrack and other sound files helps create a nostalgic mood for the game and often evokes emotional responses in players. Toby Fox has been noted stating that the re-use of melodies has made his composition of the soundtrack much easier.

Many attempts have been made at documenting all of the leitmotifs used in the game. New connections are constantly being found within the game, and it may be impossible to conclusively list them all.

Timestamps found below are approximate to one second and are sourced from this playlist, which reflects the timing of the official soundtrack.

Once Upon a Time, Part 1
Also known as "Undertale," this is one of the most frequently recurring melodies in the game. It occurs in the following songs:
 * Once Upon a Time 0:00–0:28
 * Start Menu and Menu (Full)
 * Home and Home (Music Box) 0:36–1:11
 * Hotel 0:20–0:41
 * Can You Really Call This A Hotel, I Didn't Receive A Mint On My Pillow Or Anything 0:14–0:30
 * Undertale 0:37–2:49, 3:27–4:43, 5:20–5:58
 * The Choice
 * Bergentrückung
 * ASGORE 0:00–0:02 repeating (i.e. this short phrase plays multiple times after the cited time)
 * Fallen Down (Reprise) 1:18–1:44
 * Hopes and Dreams 0:00–0:44
 * SAVE the World 0:00–0:20, 1:46–1:53
 * Reunited 0:43–1:43
 * Bring It In, Guys! 3:27–3:35, 3:47–4:05
 * Last Goodbye 0:23–0:27, 0:45–0:48, 0:56–1:02, 1:40–1:42, 1:52–2:02

Once Upon a Time, Part 2

 * Once Upon a Time 0:28–0:58
 * Home and Home (Music Box) 1:11–1:45
 * Hotel 0:41–1:22
 * Can You Really Call This A Hotel... 0:30–0:57
 * Undertale 2:49–3:27
 * Fallen Down (Reprise) 1:44–2:10
 * Reunited 1:43–2:42
 * Last Goodbye 0:02–0:21, 1:08–1:29

Once Upon a Time, Part 3

 * Once Upon a Time 0:58–1:29
 * Fallen Down (Reprise) 2:10–2:30
 * Hopes and Dreams 0:44–1:29, 1:52–2:15
 * SAVE the World 0:42–1:46
 * Final Power
 * Reunited 2:56–3:56
 * Last Goodbye 0:45–1:08

Your Best Friend (Flowey)
This leitmotif occurs in at least six songs, as well as in at least one other sound file within the game.
 * Your Best Friend
 * Your Best Nightmare 0:54–1:26, 2:00–2:27, 3:00–3:27
 * Finale 0:00–0:40, 0:57–1:52
 * Hopes and Dreams 1:29–1:52
 * SAVE the World 0:04–0:07 repeating
 * Last Goodbye 0:29–0:32 repeating
 * mus_toomuch.ogg (this plays after exhausting the random kill counter of an area)

Ruins
Ruins is another common melody, appearing in at least 11 official songs and an unused sound file.
 * Ruins
 * Waterfall 0:27–1:49
 * Quiet Water 0:05–0:32
 * NGAHHH!! 0:34–1:22
 * Spear of Justice 0:36–1:52
 * An Ending
 * Don't Give Up
 * Respite 0:35–1:54
 * Bring It In, Guys! 1:48–2:08
 * But the Earth Refused to Die 0:00–0:25
 * Battle Against a True Hero 0:44–1:36
 * mus_ruinspiano

Anticipation (Enemy Approaching)
Two to three seconds of the Anticipation leitmotif is somewhat audible within the Ghost Fight leitmotif.
 * Anticipation
 * This song plays at extremely reduced speeds when battling Monster Kid, during the final encounters with Flowey in New Home, and at the end of a "Soulless" Pacifist playthrough.
 * Enemy Approaching
 * Heartache 0:54–0:57, 0:59–1:01
 * Dogsong
 * Temmie Village 0:11–0:16 repeating
 * Tem Shop
 * Stronger Monsters 0:00–0:32, 0:38–1:03

Ghost Fight
Five songs.
 * Ghost Fight
 * Dogbass (bassline)
 * Dummy!
 * Pathetic House
 * Spider Dance

Sans
Found in four songs, one of which is never played in the game. One version can be affected by a non-Neutral Route.
 * sans.
 * It's Raining Somewhere Else 0:19–1:18, 2:00–2:39
 * This song is played slightly slower in Sans's Room.
 * Song That Might Play When You Fight Sans 0:01–0:33 (melody), 0:01–0:58 (bassline)
 * Bring It In, Guys! 0:43–0:46 (melody), 0:40–0:46 (bassline)

Papyrus
The same as Sans.
 * Nyeh Heh Heh!
 * Bonetrousle
 * This song is played at an extremely reduced speed when encountering Papyrus for the last time in the Genocide Route – "[o]ne of the catchiest songs in the OST, reduced to an eldritch horror."
 * Song That Might Play When You Fight Sans 0:42–0:58
 * Bring It In, Guys! 0:35–0:54

Snowdin Town (Snowy)
Connected to six songs.
 * Snowy 0:00–1:02
 * This song plays when fighting Snowdrake's Mother. It is heavily distorted, changing pitch and speed randomly every few seconds.
 * Because this song does not contain the second "half" of the melody found in the other songs, it is not always considered the "origin" of the leitmotif.
 * Snowdin Town 0:19–1:16
 * Shop
 * Dating Start! 0:00–1:13
 * Dating Fight!
 * Bring It In, Guys! 0:54–1:29

Hotland {times?}

 * Another Medium
 * CORE
 * Death by Glamour
 * Bring It In, Guys!

It's Showtime!
Found in four songs, plus at least one other sound file.

Minor similarities

 * The background tracks for the Start Menu all build upon one another, starting with Start Menu and ending with Menu (Full).
 * The music played in the menu at the end of a True Pacifist playthrough is an extremely slow rendition of Start Menu.
 * Determination to the unused file mus_kingdescription
 * The song is speed up by over 200% (specify) as Flowey laughs at the protagonist for dying to him.
 * Heartache 0:00–0:50 to ASGORE 0:34–1:49
 * The Joystick Config songs – Uwa!! So Temperate♫, ...Holiday♫, and ...HEATS!!♫ – are all variants of each other.
 * CORE Approach to Hotel 0:00–0:05
 * Barrier may be related to Amalgam's breathing sounds (debatable)
 * You Idiot and Burn in Despair! (background chords) to Your Best Nightmare 0:00–0:15

Megalovania
This track is part of a unique leitmotif. The melody of MEGALOVANIA is not repeated inside the game; instead, this leitmotif crosses between games, appearing most notably in Toby Fox's Earthbound Halloween Hack, the seven-year webcomic Homestuck, and in the Mother fangame Cognitive Dissonance. Remixes are slated for use in future Undertale-based fangames.

The song's use as a leitmotif is associated with an endgame event or boss battle, bringing a familiar sense of finality and the absolute to the games in which it is used.