The best time to visit Edinburgh is May to June, when days are long (light until 10 pm), temperatures reach a pleasant 17–19°C, and the city has not yet hit peak-season prices. Gardens are in full bloom and the festival calendar is warming up with the Edinburgh International Science Festival and Beltane Fire Festival.
August is the most famous month — the Festival Fringe, Edinburgh International Festival, Royal Edinburgh Military Tattoo, and Book Festival all run simultaneously, making it the most exhilarating (and expensive, and crowded) time to visit. Book accommodation six months ahead and expect peak prices.
September and October offer a sweet spot: the festival buzz fades, prices drop, autumn colour arrives in the parks and on Arthur's Seat, and the city returns to the locals. Temperatures are mild (12–15°C) and rainfall is moderate.
November to February is Edinburgh's coldest and darkest stretch. Hogmanay (31 December–1 January) is a world-renowned street party and worth the cold; the Christmas market on Princes Street runs through December. Outside the festive period, January and February see the fewest tourists and the lowest hotel rates.
March and April are unpredictable — snow is possible, but so are bright, clear days. A solid mid-season choice if you're flexible and budget-conscious.