When Litwak’s Family Fun Center & Arcade closes at nighttime, the various video game characters leave their normal in-game roles and, traveling through their cabinets’ power cables, socialize in a power strip, known as “Game Central Station”. Wreck-It Ralph, the antagonist of the video game Fix-It Felix Jr., is ostracized by its other characters for being the video game’s villain, while the titular hero Felix is praised and awarded medals. After the game’s inhabitants exclude Ralph from the game’s thirtieth-anniversary party, he sets out to earn a medal for himself to gain his neighbors’ respect. Felix worries that Ralph has “gone Turbo”—a term coined when notorious racing videogame character Turbo attempted to take over RoadBlasters out of jealousy, which resulted in both of their videogames being unplugged.
Ralph learns that he can obtain a medal from the first-person shooter, Hero’s Duty. After disrupting a videogame session, Ralph scales the game’s central beacon and obtains a medal, only to hatch a Cy-Bug, a dangerous robot insect. Ralph and the Cy-Bug stumble into an escape pod, which is launched out of the game, and crash lands in Sugar Rush, a confectionery-themed kart racing video game. With Ralph missing, his game is labeled as malfunctioning and faces being unplugged. Felix ventures to Hero’s Duty and allies with the videogame’s heroine, Sergeant Calhoun, to find Ralph and the Cy-Bug.
A young girl named Vanellope von Schweetz steals Ralph’s medal to buy her way into the nightly race that determines which characters are playable the next day, but King Candy, the ruler of Sugar Rush, forbids her from racing because she has glitches that cause her to teleport erratically. Ralph reluctantly agrees to work with Vanellope to retrieve his medal and help her win a race. They build a kart and hide out at Diet Cola Mountain, an unfinished race track, where Ralph teaches her to drive. King Candy hacks the game’s code to obtain Ralph’s medal and offers it to Ralph in exchange for preventing Vanellope from racing. He explains that if Vanellope wins she will become playable and her glitches will lead to Sugar Rush being unplugged. Unable to leave the game because of her glitch, Vanellope will be left to disappear while King Candy and his subjects become homeless in the arcade. Ralph reluctantly agrees and destroys Vanellope’s kart. Heartbroken, she declares he “really is a bad guy” and runs off distraught. Upon returning to his videogame, which has been evacuated in anticipation of it being unplugged the next morning, Ralph notices Vanellope’s image on the side of the Sugar Rush cabinet and realizes she was meant to be a playable character. He returns to Sugar Rush and learns that King Candy had deleted her code to render her a glitch, and locked up all of the other characters’ memories of her, resulting in her becoming a hated outcast.
Meanwhile, Felix and Calhoun search Sugar Rush for Ralph. Felix falls in love with Calhoun, but she abandons him when he inadvertently reminds her of her late fiancé who was killed by a Cy-Bug on their wedding day. Felix is later imprisoned in King Candy’s castle, but Ralph frees him and Vanellope, and Felix repairs the kart. Calhoun discovers a swarm of Cy-Bug eggs underground, which hatch and start attacking the videogame.
Vanellope participates in the race but is attacked by King Candy. Vanellope’s glitch causes him to be unmasked as Turbo, who took over Sugar Rush and displaced Vanellope as the main character. Vanellope glitches to escape Turbo, who is then eaten by a Cy-Bug. Ralph, Felix, and Calhoun evacuate the game, but Vanellope is trapped due to her glitches. When Calhoun points out that the Cy-Bugs can be attracted and destroyed by a beacon of light as in Hero’s Duty, Ralph decides to make Diet Cola Mountain erupt, replicating the beacon. Ralph is confronted by Turbo, now fused with the Cy-Bug that devoured him. Ralph makes the mountain erupt and falls into its depths to sacrifice himself, but Vanellope saves him using her glitching ability. The eruption lures and permanently destroys the Cy-Bugs and Turbo too.
Vanellope crosses the finish line, rebooting Sugar Rush and restoring her status and memory as Princess Vanellope, the main character of the videogame, but she chooses to keep her glitching ability. Ralph and Felix return home and their video game is restored. Felix and Calhoun marry. Vanellope’s glitches make her a popular playable character, and a content Ralph gains respect from his fellow characters.