Edinburgh did not become a Harry Potter city by accident. JK Rowling moved here in the mid-1990s as a single mother, writing in cafes because her flat was freezing and her daughter fell asleep on walks. The city seeped into the books. The medieval Old Town, with its narrow closes, blackened stone, and a castle on a volcanic plug, gave the series its atmosphere. The names on 400-year-old gravestones gave it characters. And a turreted school visible from a cafe window gave it Hogwarts.
You can walk every major Potter-connected location in Edinburgh in a single afternoon. They are clustered tightly in the Old Town, mostly within a few minutes of each other. Some connections are confirmed by Rowling herself; others are educated guesses that the fandom has turned into gospel. I have tried to be honest about which is which. This is not a theme park. There are no animatronic wands or butter beer on tap (well, one cafe does butterscotch beer). What Edinburgh gives you instead is the real city that made the books feel real. That is better.
Fair warning: some of these spots are overrun with tour groups by midday. If you care about atmosphere, start early. By 9am, Greyfriars Kirkyard is still quiet enough to hear the birds, and Victoria Street is empty enough to photograph without twenty selfie sticks in frame.