J.K. Rowling first conceived the idea for Harry Potter during a train journey in 1990.
According to Rowling, she was traveling from Manchester to London when the character of Harry Potter and the basic idea of a school for young witches and wizards came to her. She has described the train as crowded and says that she spent much of the journey imagining characters and situations because she did not have a pen available.
The idea did not become a published book immediately. Rowling developed the story, drafted material, and worked on the manuscript over subsequent years. She also experienced major personal changes, including moving to Portugal, marrying, having a daughter, and returning to the United Kingdom.
The train journey is often treated as the origin story of the series, but the finished novels contain far more than that initial spark. Rowling later built an extensive fictional history, including wizarding institutions, family histories, magical laws, and events predating Harry's birth.