The film takes place preceding the finale of Kingdom Hearts II and follows the story of Jiminy Cricket, King Mickey, Donald Duck and Goofy in Disney Castle. While organizing the records in Jiminy's journal from his travels with Sora and his friends, Jiminy Cricket's curiosity about the line "Thank Naminé" results in him finding a message that he did not write: "We must return to free them from their torment." To investigate this message, King Mickey digitizes the contents of the journal and goes into the simulated world to investigate; awakening a virtual Data-Sora on the virtual Destiny Islands to carry out the contents of the journal to uncover the identity of "them" and meets a reckless troubled data girl name Lori and her best friend, Marco.
As Data-Sora awakens on Destiny Islands, he encounters numerous "bugs", which take the form of red and black blocks, covering the whole world. Upon eliminating the Heartless and destroying the bugs, Sora, Lori and Marco traverses to other worlds infected with bugs to return them to normal, following the cloaked figure upon orders from King Mickey.
Meanwhile, Heartless begin appearing within Disney Castle, and everyone finds themselves trapped in the room. To their surprise, they are saved by Data-Sora, Lori and Marco. Suddenly, the cloaked figure reveals himself to be Jiminy's Journal taking the form of Riku, and explains that they are no longer in the real world, but the data world. Sora and Lori sent off by the Journal to discover his true identity, only to encounter Maleficent and Pete from the real world. Maleficent destroys Data-Sora's Keyblade and summons Heartless to attack him. Mickey, Lori's father, Commander Damintry, and the Journal arrive to save Sora and Lori, but the Journal is abducted by Maleficent, with Mickey giving chase. Sora and Lori makes their way through Hollow Bastion, aided by Donald, Goofy and Marco. They encounter Pete, who summons the Journal and takes control of him with the bugs to fight them, but Sora still manages to defeat the Journal, who falls unconscious.
Mickey and Damintry arrives and informs Sora that unless the bugs are destroyed, the Journal will never awaken. Sora decides to find a way to awaken the Journal, and enters Riku's data world, losing his abilities in the process. The two visit various worlds from the Data-Riku's memory and find their way back to Hollow Bastion, where they fight and defeat Maleficent. Meanwhile, King Mickey discovers that he will be returning soon to the real world, but the Journal, once completed, will have to be erased, which will mean the end of Damintry and Data-Sora's memories, but Lori and Marco will remember everything that happened. When the time comes, Sora requests more time in order to save Pete and Maleficent, who are still in the data world. Sora finds them fighting Sora's Heartless, but Pete and Maleficent are seemingly erased before he can intervene.
Sora defeats Sora's Heartless, and finds that Pete and Maleficent were rescued by the Journal through a "rift in the data". They leave the Data world shortly before Mickey returns to the real world, erasing the Journal. A new message appears claiming that a new door to a new world has been opened, which is the data of the data world added into the Journal. Mickey, realizing that this quest may be too dangerous for Lori as her father and Data-Sora has no memory of it, requests to be taken into the Data World once again.
Finding Lori in her data home world, Mickey takes her, Marco and Damintry to Castle Oblivion where Lori is confronted by a young man wearing a black coat. He tells Lori that if she wants to know the truth, she must move forward with Marco and her father through the previous worlds she and Data-Sora visited destroying bugs. During this time, she realizes that even if Damintry doesn't remember someone he's met, there's still the sadness of having forgotten them which the figure attempts to warn not to let it consume him. Lori disregards this message and fights the figure, revealed to be Data Roxas. After losing to Lori, Roxas gives her a card as Mickey appears.
Lori opens the next door to find Naminé, who reveals the bugs to have been an unintentional side effect of her attempt to restore Sora's memories. She then reveals Sora's nature as the "Key that connects everything" through his ties with herself, Roxas, and Xion. Furthermore, Naminé tells Lori about three figures (Terra, Ventus, and Aqua) also tied to Sora's heart who are the ones referred to in the message and need his help. Lori, Marco and Damintry go with Mickey into the real world and Mickey promises Naminé that he will inform the real Sora of this.
In the final scene, Mickey sends Sora a bottled letter (the same one sent by Mickey at the end of Kingdom Hearts II), which Sora reads with Riku and Kairi.
- Logan Lerman as Data Sora/Sora
- Saoirse Ronan as Lori
- Lucas Till as Data Riku/Jiminy's Journal/Riku
- Paul Butcher as Marco
- Michael Shannon as Commander Damintry
- Paul Rudd as Cid
- Alex Pettyfer as Cloud
- Josh Hutcherson as Data Roxas
- Andy Samberg as Leon
- Jamie Chung as Yuffie
- Dakota Fanning as Data Namine/Namine
- Chloe Grace Mortez as Kairi
- Joel Courtney as Tidus
- Eliza Bennett as Selphie
- Alden Ehrenreich as Wakka