Number the Stars tells the story of Annemarie Johansen, a ten-year-old girl living in Denmark during the Nazi Occupation. Annemarie's Jewish friend Ellen comes to live with the Johansens after the Nazis begin persecuting Danish Jews, impersonating Annemarie's deceased sister so that she will not be discovered. Until the end of the war, Annemarie and her family work to help Ellen and other Jews. Annemarie's story is one of courage in the face of impossible odds, and of doing the right thing even when its against the law.
A brief flashback to September 29, 1943 establishes the background to the rescue of the Danish Jews. Georg Ferdinand Duckwitz, an attache for Nazi Germany, contacts Danish social democrat Hans Hedtoft and notifies him of the intended deportation. Hedtoft warns the head of the Jewish community, C.B. Henriques, and the acting Chief rabbi, Marcus Melchior, who spread the warning.
Peter, a man working in the Danish Resistance and Lise's fiance, visits Annemarie and her family. He tells them that the Nazi SS have started closing Jewish stores. The next day, loas and her parents go to the synagogue for a Jewish holiday, but find out that the Nazis have demanded lists of names of all the Danish Jews, in order to arrest and deport them to eastern Europe. Peter takes Mr. and Mrs. Rosen with him into hiding, and Ellen hides among the Johansen family, pretending to be Annemarie's dead sister Lise (who, her parents tell her, died by a car accidentally running her over.)
Later that night the Nazis come to the Johansens' apartment for the Rosens. Annemarie secretly rips off Ellen's Star of David necklace to conceal her identity. They become suspicious because Annemarie and Kirsti have blond hair, but Ellen has dark brown hair. Mr. Johansen retrieves baby photos of his three daughters, with their names listed, which clearly show that Lise's hair was similar to Ellen's when she was a baby. Afterwards, Johansen has Annemarie moved to his brother-in-law, Henrik.
Returning to the main plot, a group of Nazi soldiers arrive and disrupt the funeral. Ellen's parents arrive shortly after. A soldier asks Annemarie's mother to open the casket. She told the soldier she would love to do so, since country doctors were not reliable, but the doctor told them that Great-aunt Birte had died from typhus, and opening the casket would spread the germs. The soldier slaps her and leaves in frustration.
Peter reads the beginning of Psalm 147:4 vs. 4 from the Bible to the group, recounting the Lord God numbering the stars again. Annemarie thinks that it is impossible to number the stars in the sky. She also thinks that the world is cold and very cruel, like the sky or the ocean. Mrs. Rosen is scared of both. Peter opens the casket and gives the warm clothing and blankets concealed within it to the Jewish families. They depart in smaller groups to reduce attention. Ellen says goodbye to Annemarie and her mother (who were among those attending the funeral).
In the morning, Annemarie sees her mother crawling in the distance because she broke her ankle. When she gets near her mother, she sees a package that seems of great importance to the Resistance, and that Mr. Rosen dropped when he accidentally tripped on a flight of stairs. Mrs. Johansen tells Annemarie to fill a basket with food and the packet, and run as fast as she can. Annemarie runs off onto a wooded path in the direction of her uncle's boat. She is halted by Nazi soldiers with dogs while going along the path. When they question Annemarie about what she is doing out so early, she lies, saying that she is taking a basket with a meal to her uncle. The soldiers do not believe her, and one of them grabs at the basket. However, the soldiers eventually let her go, and Annemarie makes it to her uncle's boat. She gives Uncle Henrik an envelope that contains a handkerchief. When the Nazi dogs taken on the boat sniff the handkerchief, they can no longer smell Uncle Henrik's hidden "cargo"– the Jewish people whom he's smuggling to safety.
Uncle Henrik returns to Denmark later that evening from Sweden. He tells Annemarie that many Jewish people, including the Rosens, were hiding in his boat. He also explains that the handkerchief in her package had a scent of rabbit blood to attract the dogs, and it contained cocaine. Several revelations are made: Peter was captured and executed by the Nazis in a public place.
Two years later, the war ends, and all of Denmark celebrates. The Jews who were forced to leave Denmark return and find that their friends and neighbors have kept up their apartments in hopes of their return. Annemarie learns that her sister Lise died, not in an accident but because the Nazis intentionally hit her with a military car because of her work in the Danish Resistance. It is unknown if Ellen or her parents return to Copenhagen.