In the Swiss Alps lives an antisocial old man. He once had a family, but there was a falling out and he hasn't heard from them in decades. Doesn't want to. Same thing happened between him and God, so he's basically sworn off any need to head down to town except for occasional groceries. He lives up there in the Alps, in a small log cabin. Owns a couple of goats. Everyone in the nearest town hates him and fears him because he's so antisocial.

Then one day a young relative, Dete, stops by... with the old man's five-year-old granddaughter Adelheid, nicknamed Heidi in tow. She says the girl's parents (the father being the old man's son) are dead, and the relative can't care for her anymore since she's getting a job in the city. So she leaves the little girl there and flees back down the mountain.

Grandfather doesn't really like the situation, but he does figure out pretty quickly that Heidi is a smart child, respectful, polite, energetic, curious, and in all ways delightful. And it isn't long before they're as close as can be. Heidi loves living in the mountains and finds ever so many things to enjoy about the details of her life there.

That's about when Dete comes back and drags Heidi off to the German city of Frankfurt. Seems her new boss has a crippled daughter who wants a playmate, and if she can get some money by bringing in a girl, Heidi's opinion on the matter is irrelevant, and the poor kid is dragged away kicking and screaming. The Grandpa closed off even more than he already did.

Stuck in Frankfurt, Heidi does become friends with the other girl, Klara. But she aches to get back to the Alps, back to her grandfather. At first she thinks that her stay is temporary, but when she's informed that it's permanent, she begins to act out in ways that surprise even her. For worse, Klara's father is well-intentioned but keeps travelling away, so she and Klara are under the care of a borderline SadistTeacher named Miss Rottenmeyer.

Meanwhile Klara's grandmother makes a visit, and introduces Heidi to Jesus, the Bible, and prayer. And later on she puts it to Heidi that when God answers prayer, sometimes He does not say "yes" right away, but either "no" or "wait". That if God said "yes" at the wrong time, it would be a sorrowful thing, but if God in His wisdom says "wait" or even "no", then in due time it will prove to be better in all ways than if He had said "yes" back at the start. This philosophy forms a cornerstone for the rest of the book.

When the family doctor diagnoses Heidi with acute homesickness after he finds her [[HeroicBSOD sleepwalking and crying]], the family is forced to send her back to the Alps, to her grandfather. She goes scarcely believing that it is happening. Once she is home, her good health and vigor come back straightaway.

What is more, she brings lessons from the city. Her friend Peter had always thought reading to be too hard a task, and his attitude had convinced Heidi that it was impossible to learn; but Klara's grandmother opened up her mind and got her to learn reading practically overnight, and now Heidi will not rest until Peter learns (at least as far as his stubborn mind will let him). And Heidi uses a tale from her beloved storybook (given her by the grandmother), the tale of the Prodigal Son, to convince her grandfather to give God another chance - that no matter how long he has forsaken God, God will yet welcome him back with open arms. The two of them start going to church, where the grandfather makes up with the pastor.

Eventually, the family from Frankfurt visit the grandfather, and are thrilled to see Heidi in such good health again. Equally charming is the atmosphere, though it is a trying hike up the mountain from the town below. The grandfather proves that he is capable of caring for an invalid (a skill learned from caring for his crippled commander, back in the war), and persuades the family to let Klara sleep overnight in the cabin, a move greeted with delight by both girls. The family heads back down to the inn.

The next day, the children are about to enjoy a picnic with Peter. But jealousy burns inside Peter, for until now Heidi was his friend alone, and here has come this other child to take up her attention. In a fit of rage, he hurls Klara's wheelchair down the mountainside.

When Heidi discovers the wheelchair gone (but imagines that the wind took it), she is not deterred, but convinces Peter to help her support Klara as they walk up to the picnic site. Between this and the Grandfather's later attentions, Klara manages to strengthen her weak legs enough to walk, though it hurts terribly and she cannot do it unaided (yet).[[note]]Anyone reminded of ''Literature/TheSecretGarden''?[[/note]]

When the grandmother returns, she finds a Klara who bravely walks to her - on the Grandfather's arm - and she is so happy that she doles out treats. In the midst of this, the truth about the wheelchair comes out, but the grandmother takes it in stride as God's providence (providing reason for Klara to experiment with walking). Instead of punishing Peter, she rewards him with a little money, that works out to "two pennies a day"; when he misunderstands her as promising this for the rest of his life, she laughs and declares it will be written into her will, two pennies a day for him the rest of his life.

So Heidi understands with clarity the way things worked out for the best because God did not answer her prayer immediately, but let things happen in good time, no matter how much she hated to be away from her grandfather. And they all live HappilyEverAfter.