In writing the novel, Montgomery was inspired by notes she had made as a young girl about a couple who were mistakenly sent an orphan girl instead of the boy they had requested, yet decided to keep her. She drew upon her own childhood experiences in rural Prince Edward Island, Canada. Montgomery used a photograph of Evelyn Nesbit, which she had clipped from New York's Metropolitan Magazine and put on the wall of her bedroom, as the model for the face of Anne Shirley and a reminder of her "youthful idealism and spirituality."
Montgomery was inspired by the "formula Ann" orphan stories (called such because they followed such a predictable formula) which were popular at the time and distinguished her character by spelling her name with an extra "e". She based other characters, such as Gilbert Blythe, in part on people she knew. She said she wrote the novel in the twilight of the day, while sitting at her window and overlooking the fields of Cavendish.