Wreck-It Ralph (voice of John C. Reilly) longs to be as beloved as his games perfect Good Guy, Fix-It Felix (voice of Jack McBrayer). Problem is, nobody loves a Bad Guy. But they do love heroes so when a modern, first-person shooter game arrives featuring tough-as-nails Sergeant Calhoun (voice of Jane Lynch), Ralph sees it as his ticket to heroism and happiness. He sneaks into the game with a simple plan: win a medal, but soon wrecks everything and accidentally unleashes a deadly enemy that threatens every game in the arcade. Ralph's only hope is Vanellope von Schweetz (voice of Sarah Silverman), a young troublemaking glitch from a candy-coated cart racing game who might just be the one to teach Ralph what it means to be a Good Guy. But will he realize he is good enough to become a hero before it's Game Over for the entire arcade?
The film takes place in Litwik's Arcade, and concerned the character of Wreck-it-Ralph, the bad guy in the Fix-It-Felix Jr video game.
When we are introduced to Ralph, he is attending 'Bad-anon,' a support group for the video game bad guys that inhabit the arcade's games. Ralph explains that after 30 years of doing the same thing and getting no respect for his job, he feels that he doesn't want to be the bad guy anymore. The other members claim that he can't mess with the program of his game, and soon finish the meeting, leaving Ralph still dejected.
Going through 'Game Central Station' (a power strip with surge protectors that has all the arcade's game plugged into it), Ralph returns to his game, only to see the inhabitants of the Niceland apartments throwing a party (even Pac-Man is there!). Ralph is upset that he wasn't invited, and attempts to get in. However, upon seeing a special cake that was made with all the Nicelanders and Felix on top and Ralph in a pit on the bottom, he gets upset. When one of the Nicelanders claims that he's just the bad guy who wrecks things,' Ralph destroys the cake in a fit of rage and angrily leaves, intending to somehow get a medal of his own, and prove he can be a hero.
Going off to a bar-game called Tapper's, Ralph is unsure what to do, when he encounters a soldier from a new first-person shooter named "Hero's Duty." The soldier is a nervous wreck from hunting bugs, but when Ralph hears there's a medal at the end of the game, he eagerly takes up the soldier's armor, and heads off through 'Game Central Station,' to board the transport to "Hero's Duty." On his way there Q*Bert, a homeless character whose game has been unplugged is at the station and he tell him where he is going, then is off.
Ralph eagerly gets ready for a new round of the game, whose squadron is being led by Sgt Calhoun (Jane Lynch). However, once the game starts, Ralph realizes he's in way over his head, when the group is bombarded by giant mechanical 'Cy-bugs,' that take on the properties of whatever they consume. Ralph accidentally gets the first-person shooter (aka a kid playing the game inside the arcade) killed, and the game ends. As it does, a giant beam of light shoots out of the top of a nearby tower, attracting the Cy-bugs, and incinerating them as they are drawn into its light.
As the game begins to reset for the next player, Ralph learns that the medal he wants is at the top of that tower. Removing his armor, he climbs the tower, and finds himself in a room full of Cy-bug eggs. Making his way through them all, he finds the medal (with the name 'Hero' on it) floating in the center of the room. Reaching it and taking it, a group of holographic soldiers appear, and salute Ralph on a job well done.
Ralph gets a bit too excited, and accidentally steps on an egg, releasing a Cy-bug hatchling. It begins to attack Ralph, who attempts to get away in an escape pod. However, the pod takes off with the Cy-bug inside it. Sgt Calhoun and the others see it take off, and it escapes into the portal to 'Game Central Station.' It bounces around the station, before sending Ralph into a nearby racing game called 'Sugar Rush.' Crash-landing, the ejector seat sends Ralph in one direction, and the Cy-bug in another, sending it into a deep pit.
Meanwhile, in Fix-It-Felix, Jr, the denizens of the game suddenly realize that Ralph is missing when a player attempts to play a game. The players panic, causing the player to assume something is wrong with the game when 'the wrecking guy' doesn't show up. The arcade's owner, Mr Litwik, is informed, and an 'out of order' sign is placed over the game. The game's denizens are unsure where Ralph may have gone, but get a surprise when Q*Bert shows up to say that Ralph was seen entering the game 'Hero's Duty.'
With the possibility that without Ralph, the game's plug will be pulled and their time will end, Felix heads into 'Hero's Duty' to find Ralph. After almost being killed by Sgt Calhoun and her soldiers, Felix explains he is looking for Ralph, and also slowly falls in love with the Sergeant's 'hi-definition' looks. They then leave the game, and after finding out which way the escape pod went, set off into 'Sugar Rush'. Calhoun is greatly concerned, because Cy-bugs can multiply when plenty of food is available, i.e. the candies and sweets of 'Sugar Rush', and the possibility of the game being overrun by them is highly possible.
Meanwhile, Ralph finds his medal hanging from the top of a candy-cane tree, along with a little girl named Vanellope Von Schweetz (Sarah Silverman). Vanellope ends up taking the medal before Ralph can get to it, and he then attempts to track her down.
Vanellope ends up using the medal in place of a game coin for a major race to decide which of the top 9 racers (along with their ruler, King Candy (Alan Tudyk)) will get to be the chosen racers for the next day's play of the arcade (this is how the game randomly selects new racers for each day). However, when her entry is seen on the board, King Candy orders her to be caught, but this is interrupted when Ralph comes barreling through the starting line, attempting to get Vanellope himself, and destroying the area.
Ralph is then captured and brought before King Candy. The King is at first shocked that Ralph appears to be 'game-jumping,' but Ralph claims that all he wants is his medal back. However, the King informs him that since it's now been entered into the game's programming, the only way he can get it back is if he wins the race.
Ralph then leaves the King's castle still upset, but upon seeing several of the racers nearby, he figures maybe he can explain to them to win the race and get his medal for him. However, his thoughts are sidelined when the racers come across Vanellope, who has finished a small pedal-cart she intends to use in the race. As Ralph watches, the other kids say she can't enter because she's a glitch, and then wreck her cart. Ralph scares them off, and Vanellope decides to make a deal with Ralph: if he helps her get a new cart for the race, she'll win back his medal for him. Ralph is at first unsure of the alliance, but agrees to it.
Meanwhile, Felix and Calhoun have discovered the crashed escape pod, but no sign of Ralph or the Cy-bug. Calhoun attempts to use a detector for finding the bug, but it can't focus because of the sugar particles interfering with the detector. As they continue on their journey, the end up in a pit of Nes-quik sand, and Felix is able to get them out by grabbing onto some Laffy-Taffy hanging from the trees.
After they get out, Felix makes mention that some would consider Ralph going outside of his game to be 'turbo.' When Calhoun seems confused at this term, Felix explains where it came from. Many years ago, there was a racing game in the arcade called "Turbo-Tastic," whose main racer loved to win, and grew egotistical about it. When the arcade got a new racing game called "Roadblasters," Turbo abandoned his game, and entered into "Roadblasters," wrecking it. Because of this, both games were unplugged, and presumably, Turbo died when he was unable to return to his game.
Back in the world of "Sugar Rush," Ralph and Vanellope break into a cart-baking factory, and Ralph helps Vanellope as best as he can. However, his attempts to help make the car look like a bakery-fueld mess, but Vanellope loves it anyway, and has Ralph sign his name on the side in icing. However, their intrusion is soon found out, and King Candy and his police force soon arrive.
Ralph tells Vanellope to start driving, only for her to tell him that she doesn't know HOW to drive a cart! Ralph then uses his giant hands to help propel them away from the pursuing King and his police force, losing them when Vanellope directs him to a secret entrance near Diet Cola mountain.
Inside, Ralph finds a giant pit over which Mentos stalactites hang overhead. When one drops into the soda, it causes a heated geyser to erupt.
Nearby, Ralph also finds where Vanellope lives, having taken up refuge inside the mountain because no one likes her, or will give her a chance to prove she can race. Seeing how she just wants a chance to prove herself like he does, Ralph helps her learn how to race her vehicle.
As they prepare to take off for the big race, Vanellope rushes back into the mountain to get something. It is then that King Candy shows up, and offers Ralph back his 'Hero' medal. The King then explains to Ralph that he is giving the medal to him, if he'll prevent Vanellope from racing. Ralph claims he won't, when the King tells him that it is essential to saving her life.
As Vanellope is a glitch, she has trouble being a stable racer, and may end up popping up all over the game. If she is chosen to race, and the players don't like her, the plug could be pulled on Sugar Rush. However, because Vanellope is a glitch, she won't be able to escape into Game Central Station, and die within the game.
The King leaves, and Vanellope returns, presenting Ralph with a Heart-shaped cookie medal, calling him both a snotbrain, and her hero for helping her. However, Ralph then attempts to get her to reconsider the race, when she sees he's got his 'Hero' medal back. Ralph then explains what the King told him, but she says she doesn't care and wants to race! Claiming he's saving her life, Ralph hangs Vanellope from a nearby tree, and breaks her cart. Heart-broken that he has ruined her chance, she claims he 'really is a bad guy,' and rushes back to her hide-out.
Over at the King's castle, Felix has parted ways with Calhoun who is still looking for the Cy-bug, and arrives at the castle door. Felix meets the King's assistant, a little sourball. Realizing that Felix is from Ralph's game, he sends him to the king's Fungeon.
Now that he's got his medal back, Ralph returns to his game, but finds the Niceland apartments are empty, except for one lone tenant, who explains everyone else headed to Game Central Station for safe haven. Ralph claims he got a medal that proves he's a hero, but in the wake of the game's plug being pulled at dawn if it doesn't function properly, the need to prove himself seems nil. Upset that he seems to have made a mess of things for his game as well as for Vanellope, he flings his 'Hero' medal at the case of the arcade game, causing the out-of-order sign to fall slightly. As it does so, he can see the gaming console for 'Sugar Rush,' and finds a strange sight: even though she is considered a glitch, Vanellope is on the advertising graphics for the game on its gaming console!
Ralph then returns to 'Sugar Rush' and heads for diet cola mountain, finding the King's sourball cleaning up the remnants of Vanellope's cart. Ralph then gets the little sourball to tell that King Candy changed around Vanellope's code, but as to why he did this, the sourball has no clue. He also tells Ralph that both Felix and Vanellope are being held in the King's Fungeon, and Ralph sets out there along with the garbage can containing the broken pieces of Vanellope's kart.
Ralph rescues Felix first, and the two reconcile, with Felix finally understanding why Ralph seemed to be acting so strange when he burst in on the party the other day.
Using Felix's magical hammer, they repair Vanellope's cart, and manage to free her, with Ralph first admitting what a moron he was.
As the race gets underway, Vanellope quickly takes off, leaving Felix and Ralph at the starting line. However, Calhoun also arrives, alerting them that the Cy-bug has eaten plenty under the grounds of Sugar Rush, and has multiplied into a giant army. As if on cue, they burst up around the stadium. Calhoun attempts to kill them off, but there are just too many. She quickly yells for those nearby to head towards the portal to Game Central Station. With the game too overrun with the creatures, they'll need to kill the game to end them. Realizing that it'll mean the end for Vanellope, Ralph stays by the finish line as long as he can, figuring if Vanellope can at least cross the finish line, she'll be able to escape.
Meanwhile, the race continues onward, and Vanellope finally catches up to King Candy. However, as the two battle car-to-car, the King begins to glitch, and we see that he is Turbo in disguise! It soon becomes apparent that he took over 'Sugar Rush', locking up the memories of the other racers, thus making her a glitch!
Luckily, Vanellope manages to get free, and focuses her glitching powers to break free of the Turbo's grasp, and speed into 1st position. As he attempts to catch up to her, a Cy-bug emerges in front of his car, and gobbles him up.
As she nears the finish line, Vanellope's car is thrown off-track by another horde of Cy-bugs, and she is scooped up by Ralph, who takes her towards the portal to Game Central Station as the horde devours the finish line. Almost everyone else is able to get through but Vanellope. Ralph tries as hard as he can to take her, but it's no use.
As Calhoun continues to blast away as many Cy-bugs as she can, she explains the only way they would be able to stop the horde, is if they had a beam of light to blast them away, like in "Hero's Duty." Ralph suddenly flashes back to Diet Cola Mountain, and the group of Mentos stalactites, and formulates a plan!
Grabbing a hoverboard from Calhoun, he flies towards the mountain. Using his fists, he attempts to dislodge the Mentos at the top, to create a new beam of killing light. However, his plans are interrupted when a Cy-bug appears, with the colors and head of King Candy and Turbo. The newly-powered-up tyrant knocks Ralph around a bit, saying he is the most powerful virus in the arcade and will attempt to take over all the other games for revenge, Ralph battles Turbo, but Turbo dislikes being stopped and quickly overpowers Ralph, flying him above the mountain and sarcastically forcing him to watch Cy-Bugs close in on Vanellope. Ralph manages to break free from Cy-bug Turbo, aiming towards the Mentos. As he hits them, and they fall towards the cola pit deep within the mountain.
Luckily, before he hits the bubbling pit, Vanellope gets back in her cart, and focusing her glitching power, manages to save Ralph before the major eruption.
The eruption shines a bright light, which in turn draws most the Cy-Bugs, to their destruction. Turbo being more powerful then the others is able to resist for a short time but his Cy-Bug programming overwhelms him and he flies into the lava as well, killing him. Because video game characters who die outside their own game are unable to regenerate ever, this means that the Cy-Bugs gets destroyed and Turbo gets destroyed permanently to his death, vowing his revenge, because which causes King Candy's code to be destroyed forever.
After this, Vanellope manages to cross the finish line, and due to Turbo's brainwash, the memories of the other players are reprogramed, and Vanellope is returned to being the Princess of Sugar Rush and a true character again. However, she claims that she doesn't really want to be a Princess, and feels that a government run by a President would be more her style. Turbo has disappeared forever (Sour Bill, Wynchel and Duncan, the Sugar Rush Racers and the Citizens, never heard of him again).
In the aftermath, Felix and Calhoun are wed (even though their games will keep them apart by day in the arcade). Vanellope is now a regular racer in 'Sugar Rush,' though she still uses the cart that Ralph helped her build, and her glitching power makes her a big hit with the players.
As for Ralph, the Nicelanders finally acknowledge and appreciate him. Ralph also claims that even though he still gets pitched off the top of the apartment building in his game, he loves the view through the glass of the video game box, and seeing his friend Vanellope doing what she loves, he feels great.