Pessimistic 10-year-old Richard Tyler lives life based on statistics and fears everything. His exasperated parents have tried multiple ways to build up his courage to little success. Richard is sent to buy a bag of nails for building a treehouse. However, Richard gets caught in a harsh thunderstorm and takes shelter in a library. He meets Mr. Dewey, an eccentric librarian who insists that he is in need of a special book and gives him a library card, despite Richard's protests. Searching for a phone, Richard finds a large rotunda painted with many famous literary characters. He slips on water dripping from his coat and falls over, knocking himself out. Richard awakens to find the rotunda art melting, which washes over him and the library, turning them into illustrations.
He is met by the Pagemaster, the mythical Keeper of Books and Guardian of the Written Word. Richard asks for directions to the exit, so the Pagemaster sends him through the fiction section toward the green neon exit sign. Along the way, Richard befriends three anthropomorphic books: Adventure, a swashbuckling pirate-like book; Fantasy, a sassy but caring fairy tale book; and Horror, a fearful "Hunchbook" with a misshapen spine. The three agree to help Richard if he checks them out using his new library card. Together, the quartet encounters classic-fictional characters. They meet Dr. Jekyll who turns into Mr. Hyde, driving them to the open waters of the Land of Adventure. However, the group is separated after Moby-Dick attacks, following the whale's battle with Captain Ahab. Richard and Adventure are picked up by the Hispaniola, captained by Long John Silver. The pirates go to Treasure Island, but find no treasure except for one gold coin, nearly causing a mutiny. Fantasy and Horror return and defeat the pirates. Silver attempts to convince Richard to leave with him but surrenders when Richard threatens him with a sword.
In the fantasy section, Richard sees the exit sign on the top of a mountain. However, Adventure's bumbling awakens a dormant dragon. Richard tries to fight the dragon with a sword and shield, but the dragon swallows him. Richard finds books in the dragon's stomach and uses a beanstalk from Jack and the Beanstalk to escape through the dragon's mouth. He and the books climb the beanstalk to reach the exit. They enter a large dark room where the Pagemaster awaits them. Richard accuses the Pagemaster of causing the horrors that he suffered, but the Pagemaster reveals the journey was intended to make Richard face his fears. Dr. Jekyll, Captain Ahab, Long John Silver, and the dragon reappear in a magical twister and congratulate him. The Pagemaster swoops Richard and the books into the twister, sending them back to the real world.
Richard awakens, finding Adventure, Fantasy, and Horror lying next to him as real books. Mr. Dewey finds him, and, even though the library policy only allows a person to check out two books at time, lets him check out all three books "just this once".
Richard returns home a braver boy, sleeping in his new treehouse with his books, where his parents find him after searching all over town believing him to be missing.