Compactness is a major urban form parameter that affects the accessibility of solar energy in the built environment. Here we explore the relation between various compactness indicators and solar potential in the 16 neighbourhoods (11,418 buildings) constituting the city of Geneva Switzerland). The solar potential is assessed for building integrated photovoltaics (BiPV), solar thermal collectors (STC), and direct gain passive solar systems. The hourly solar irradiation on each of the building surfaces over one year period is calculated using CitySim simulations, while taking the effects of irradiation threshold for roof and facades into account. With increasing compactness, the annual solar irradiation decreases from 816 to 591 kWh/m2. When passing from dispersed to compact neighbourhoods, the BiPV potential (given as percentage of total area) for facades decreases from 20% to 3%, the STC potential from 85% to 49%, and the passive solar heating potential from 21% to 4%, whereas for roofs the BiPV potential decreases from 94% to 79% and the STC potential from 100% to 95%. The solar potential for roofs, therefore, is much less affected than that for facades by the compactness. The results should be of great help for urban-form energy optimisation and building retrofitting interventions.