Riley Andersen is born in Minnesota and within her mind, five personifications of her basic emotions—Joy, Sadness, Fear, Disgust, and Anger—gradually come to life and influence her actions via a console in her mind’s Headquarters. As she grows up, her experiences become memories, stored in colored orbs, which are sent into long-term memory each night. Her five most important “core memories” (all of which are happy ones) are housed in a hub that each power an aspect of her personality which take the form of floating islands. In Headquarters, Joy acts as a de facto leader to maintain Riley’s cheerful childhood, but since she and the other emotions do not understand Sadness’ purpose, she frequently tries to keep Sadness away from the console.
At the age of eleven, Riley and her parents move to San Francisco for her father’s new business. Riley has poor first experiences: the new house is cramped and old, the moving van with all their belongings was misdirected, her father is under stress from his business, and a poor encounter at a pizza restaurant leaves her disheartened. When Sadness begins touching Riley’s happy memories, turning them sad, Joy tries to guard them by isolating her. On Riley’s first day at her new school, Sadness accidentally causes Riley to cry in front of her class, creating a sad core memory. Joy, panicking, tries to dispose of it, but accidentally knocks the other core memories loose during a struggle with Sadness, deactivating the personality islands. Joy, Sadness, and the core memories are sucked out of Headquarters, and taken to the maze-like storage area of long-term memory.
The other emotions, Anger, Fear, and Disgust try to maintain Riley’s happiness in Joy’s absence with disastrous results, distancing her from her parents, friends and hobbies. As a result, her personality islands gradually begin to crumble and fall, one by one, into the “Memory Dump”, an abyss where memories are forgotten. In desperation, Anger inserts an idea into the console prompting Riley to run away, believing that her return to Minnesota will enable her to make new happy core memories.
Joy and Sadness encounter Bing Bong, Riley’s childhood imaginary friend, who suggests riding the train of thought back to Headquarters. The three eventually catch the train, but it is halted when Riley falls asleep. They succeed in manipulating Riley’s dreams to wake her and restart the train, but it is derailed when the “Honesty Island” collapses (when Riley steals her mother’s credit card and begins to run away). In desperation, Joy tries to ride a “recall tube” back to Headquarters, but abandons Sadness since close proximity to Sadness will cause the core memories to turn sad, which Joy believes will hurt Riley. But as she takes off, the ground below the tube collapses, breaking the tube and plunging Joy and Bing Bong into the Memory Dump. At the bottom, Joy then begins to lose hope, but discovers a sad memory of a hockey game that became happy when Riley’s parents and friends comforted her. Joy realizes that Sadness serves an important purpose: to create empathy in others when Riley is emotionally overwhelmed and needs help.