A pirate known as Burger Beard embarks on a journey to Bikini Atoll, where he unearths a magical book that can bring to life anything written within its pages. This enchanted tome narrates the thrilling exploits of SpongeBob SquarePants, who juggles his duties in the bustling underwater city of Bikini Bottom. SpongeBob works at the beloved Krusty Krab restaurant, where he diligently flips Krabby Patties while guarding the secret recipe from the devious Plankton, owner of the competitor Chum Bucket.
One fateful day, daring Plankton launches a brazen attack on the Krusty Krab, determined to snatch the precious formula. After a chaotic clash featuring giant food items and condiments, Plankton pretends to capitulate, using a decoy to weasel his way into Mr. Krabs' vault. He successfully makes off with the formula, leaving only a cleverly crafted fake in its place. In a moment of conflict, SpongeBob confronts Plankton, but the formula inexplicably vanishes from sight.
With the secret formula gone, the Krabby Patties cease to be produced, causing an insatiable hunger among customers. Though Mr. Krabs suspects Plankton is to blame, SpongeBob understands Plankton's innocence. The duo finds a way to evade Krabs, floating away in a soap bubble. As Bikini Bottom plunges into despair due to the absence of its beloved Krabby Patties, a scuffle between Burger Beard and a flock of seagulls leads to the book's page being cast into the ocean, landing fortuitously on Sandy Cheeks' tree dome.
Determined to restore the Krabby Patty, SpongeBob suggests joining forces with Plankton, and together they work on a time machine to rewind to the moment just before the formula's disappearance. Upon traveling into a distant future, the duo encounters Bubbles, a magical bottlenose dolphin overseeing the galaxy, and accidentally cause him to lose his job. After narrowly escaping his wrath, SpongeBob and Plankton retrieve the formula from their past, only to find that it is the counterfeit left by Plankton previously.
In a moment of desperation, Sandy proposes a ritual sacrifice to appease the "sandwich gods," and SpongeBob courageously steps forward. As the townsfolk gather for this unusual event, SpongeBob is alerted by the scent of Krabby Patties—a smell that Mr. Krabs quickly catches as well. Followed by the crowd, they trace the aroma to the surface, where Bubbles returns, expressing his relief at being unemployed. In gratitude, he magically grants SpongeBob and his friends the ability to breathe on land to pursue the tempting scent.
The team washes ashore only to discover that it leads back to Burger Beard's ship, which he has converted into a food truck. It is revealed that Burger Beard used the magical book to pilfer the formula for himself. Trapped on his floating fortress, the group is banished to an island swarming with pelicans. Using a page handed to him by Sandy, SpongeBob transforms himself and his companions into superheroes. They return to confront Burger Beard, who drives off with the stolen formula.
In the midst of a dramatic battle, the team manages to destroy the magical book, but Burger Beard proves to be a formidable opponent. Just when things look dire, Plankton appears as a muscle-bound hero, bravely taking on Burger Beard. With SpongeBob's assistance, they successfully reclaim the formula, banishing Burger Beard back to Bikini Atoll. The friends use the magic from the final page of the book to return to Bikini Bottom, where the Krabby Patties can once again flow, restoring the city to its former lively state as Plankton returns to his role as a crafty rival.