Hans Christian Andersen was born in Odense, Denmark, to a father who claimed to be related to nobility. After school, he worked as a weaver's apprentice and as a tailor's assistant. At 14, he moved to Copenhagen to be an actor, and was accepted into the Royal Danish Theatre. His career ended when his voice changed, and he decided to become a writer. He published his first story, The Ghost at Palnatoke's Grave, in 1822. An acquaintance paid all expenses to send him to grammar school in Slagelse. He also attended school at Elsinore until 1827. He later admitted that his school years were the darkest and bitterest of his life.
After school, Andersen resumed writing. In 1829, he started to see his first successes, publishing a short story, "A Journey on Foot from Holmen's Canal to the East Point of Amager", and a collection of poems. In 1833 he received a traveling grant from the King and set out to travel through Europe. He published his first novel, The Improvisatore, in 1835. He also published the first set of Fairy Tales, following up with more stories in 1836 and 1837. Although they were not initially successful, they have become his best-known works. He wrote a well-received poem, Jeg er en Skandinav, which celebrated Scandinavism, in 1839.
In 1857, following a visit to Charles Dickens in England, Andersen met Danish actor Lauritz Eckardt and Danish ballet dancer Harald Scharff in Paris. In 1860, he met them again in Bavaria, and the three of them spent a week in Munich together. Anderson fell in love with Scharff, and started corresponding with him when Scharff and Eckardt left Munich. They were united when Andersen returned to Copenhagen in 1862. Their affair lasted for over a year before it was ended by Scharff, and Andersen did not have another serious relationship.
In 1872, Andersen was injured in a fall, and he died of his injuries in 1875.