Adelheid (called Heidi) is five years old when her aunt Dette, who has raised Heidi since her parents’ death four years earlier, takes Heidi to live with her formidable grandfather on the Swiss Alps. Dette has found a promising job in Frankfurt, but cannot leave while still Heidi’s guardian. The only relative left is Heidi’s grandfather, and in Dette’s opinion, he should take some responsibility. Alm-Onji (Alps-Uncle), as Heidi’s grandfather is commonly known, has a fearsome reputation with the villagers of Dörfli, as rumors claim that in his youth he killed a man. Now he lives a solitary life with his dog Josef in a cabin halfway up the mountain. However, Heidi quickly wins her way into his heart with her enthusiasm and intelligence, firmly establishing herself in his life. She spends her summer days on the mountain top with the goatherd Peter, whose responsibility it is to take the villagers’ goats to the high mountains for pasture, and her winters occasionally visiting Peter’s grandmother, a blind old woman whose dream is to one day hear her cherished book of psalms read to her. Alm-Onji’s misanthropy prevents Heidi from going to school, of which she has no experience anyway.
Heidi continues to live happily in the mountains until Aunt Dette returns from the city, excited about a good opportunity for Heidi. A wealthy German businessman, Mr. Sesemann, is searching for a companion for his crippled daughter. Thwarted by Alm-Onji, Dette tricks Heidi into accompanying her, ostensibly to get a present for Peter and her grandfather. Promised that she can return at any time, Heidi is taken to Frankfurt. There, Dette abandons her to the care of Miss Rottenmeier, the strict, no-nonsense governess in charge of Clara’s welfare. Heidi and Clara quickly become friends, and Heidi quickly turns the household topsy-turvy with her escapades and well-meaning faux pas. Clara is enchanted by Heidi’s stories of the Alps, which paint a picture of a life completely different from the sheltered and lonely one she is accustomed to. Her father is mostly away on business, and Clara’s only constant companions until now are the servants and her canary.
Heidi’s longing to return home and occasional attempts to escape are punctuated by the occasional distractions of new friends. She smuggles a small kitten into the house, and Clara and she care for it until Mrs. Rottenmeier discovers it and has it thrown out. Clara’s doctor befriends her, and occasionally keeps a benevolent eye on her, but it is Clara’s grandmother that has the most impact. On one of her rare visits to Frankfurt, she and Heidi become fast friends. Under her kindly tutelage, Heidi finally learns how to read, to the astonishment of the tutor who has struggled for months to do the same. However, the old woman’s departure home again proves a turning point for Heidi. Forbidden by Mrs. Rottenmeier to ever mention or even think of the Alps again, Heidi rapidly goes into a decline, eventually becoming a sleep-walker whose ghostly passage through the hallways terrorizes the household.
Summoned home to deal with the haunting, Mr. Sesemann, with the aid of the doctor, catch Heidi in the middle of the night. The doctor diagnoses Heidi’s condition and persuades Mr. Sesemann to send the girl back to her Alps before she dies of homesickness. Clara is only reconciled by the promise that she will be allowed to visit Heidi in her mountains. Under the care of Sebastian, the kindly butler, Heidi embarks on the long trip home, finally returning to the arms of her overjoyed grandfather, Peter and his family.
Heidi’s return and her enjoyment of reading prompt Alm-Onji to partially restore a ruined house down in the village, where they retire the following winter so that Heidi can start going to school. Over the course of the season, Heidi and Alm-Onji become friendly with the villagers, and Peter builds his own sled and wins a local race. The subsequent spring, they return to the mountain in the Alps, bidding farewell to their new friends. In Frankfurt, Clara, who has been longing to see her friend again, reminds her father of his promise to her, but he reminds her that the conditions in the Swiss Alps may be too harsh for her to handle. The doctor is sent to the Alps in her place, to determine whether it is an appropriate environment for a crippled, sick young girl. Heidi, Peter, Alm-Onji, and the limitations of the terrain convince the doctor that this may be just the place for Clara to try her legs again.
In due course, Clara comes to the Alps with Mrs. Rottenmeier, whose disapproval of the rustic conditions and fear of animals is patent. However, Clara’s grandmother soon arrives, and after seeing first-hand the vast improvement in Clara’s condition, sends Mrs. Rottenmeier home, commending Clara to the Alm-Onji’s care before departing herself. After having established that Clara’s legs are capable of functioning, the children and Alm-Onji begin to work on Clara’s physical therapy. Eventually, Clara is able to walk without assistance and returns home with her father and grandmother, promising that she will return the following spring to be with her friends again.