The story is split between parallel narratives. The odd-numbered chapters take place in the 'Hard-Boiled Wonderland', although the phrase is not used anywhere in the text, only in page headers. The narrator is a "Calcutec", a human data processor/encryption system who has been trained to use his subconscious as an encryption key. The Calcutecs work for the quasi-governmental System, as opposed to the criminal "Semiotecs" who work for the Factory and who are generally fallen Calcutecs. The relationship between the two groups is simple: the System protects data while the Semiotecs steal it, although it is suggested that one man might be behind both. The narrator completes an assignment for a mysterious scientist, who is exploring "sound removal". He works in a laboratory hidden within an anachronistic version of Tokyo's sewer system. The narrator eventually learns that he only has a day and a half before his consciousness leaves the world he knows and delves forever into the world that has been created in his subconscious mind. According to the scientist, to the outside world this change will seem instantaneous, but in the Calcutec's mind, his time within this world will seem almost infinite.
The even-numbered chapters deal with a newcomer to "The End of the World", a strange, isolated Town, depicted in the frontispiece map as being surrounded by a perfect and impenetrable wall. The narrator is in the process of being accepted into the Town. His Shadow has been "cut off" and this Shadow lives in the "Shadow Grounds" where he is not expected to survive the winter. Residents of the Town are not allowed to have a shadow, and, it transpires, do not have a mind. The narrator is assigned quarters and a job as the current "Dreamreader": a process intended to remove the traces of mind from the Town. He goes to the Library every evening where, assisted by the Librarian, he learns to read dreams from the skulls of unicorns. These "beasts" passively accept their role, sent out of the Town at night to their enclosure, where many die of cold during the winter. It gradually becomes evident that this Town is the world inside of the narrator from the Hard-Boiled Wonderland's subconscious (the password he uses to control different aspects of his mind is even 'end of the world'). The narrator grows to love the Librarian while he discovers the secrets of the Town, and although he plans to escape the Town with his Shadow, he later goes back on his word and allows his Shadow to escape the Town alone.
The two storylines converge, exploring concepts of consciousness, the unconscious mind (or as it is incorrectly referred to, subconscious) and identity.
In the original Japanese, the narrator uses the more formal first-person pronoun watashi to refer to himself in the "Hard-Boiled Wonderland" narrative and the more intimate boku in the "End of the World". Translator Alfred Birnbaum achieved a similar effect in English by putting the 'End of the World' sections in the present tense.