Many countries are changing their legislation to enable photovoltaic (PV) sharing beyond building boundaries. This work aims to investigate the profitability and optimal installation capacities of PV systems for energy communities (ECs) in comparison to individual buildings. To gain a wide spectrum of results, four characteristic settlement patterns with different building types are defined, ranging from urban to suburban and historical to rur. Many countries are changing their legislation to enable photovoltaic (PV) sharing beyond building boundaries. This work aims to investigate the profitability and optimal installation capacities of PV systems for energy communities (ECs) in comparison to individual buildings. To gain a wide spectrum of results, four characteristic settlement patterns with different building types are defined, ranging from urban to suburban and historical to rural areas. Analytically, a mixed-integer linear optimisation model is developed to maximise the net present value over a time horizon of 20 years. The results show that the profitability of implementing optimally-sized PV systems increases when forming ECs compared to the situation of considering buildings individually. The more different the load profiles, the more synergy effects, and the higher the cost saving potential. Consequently, a sensitivity analysis shows that taking into account large customers can increase the profitability of PV installation for the community significantly because large roof/facade areas are provided for optimal PV installation. In addition to a broad participant portfolio, a change in the technology set-up can have a positive influence. Battery- and hot water storage which complement PV systems and heat pumps can contribute to saving energy costs, if only marginally.••••System analysis to determine cost-optimal PV capacities in energy communities (ECs).••Four characteristic settlement patterns with typical buildings and tenant portfolio.••Determining added value of ECs between multiple buildings vs. individual buildings.••PV systems most profitable in cities due to load profile diversity (synergy effects).••Energy communitySettlement patternsBuilding-attached/integrated PVNet present valueWith the increased diffusion of renewable energy – especially photovoltaic (PV) systems – the energy system undergoes a transformation from centralised to decentralised structures. In regions with a less reliable electricity grid infrastructure, the microgrid concept is a common solution for integrating decentralised electricity generation units. However, microgrids are purely technical concepts, with two limitations: (i) obligatory participation of individuals which (ii) live within close geographical range. These limitations are overcome by a novel concept known as the energy community (EC). ECs are market-based concepts that neither enforce participation nor is geographical proximity a binding constraint.Until recently, the implementation of ECs was prevented in most countries by the missing legislative background and regulatory obstacles. Nevertheless, many countries have managed to adapt the legislation and PV sharing concepts can be realised at least at a building level. Recent studies such as [23,24] provide strong evidence for the financial benefits of shared PV within multi-apartment buildings. Thus, it is to be assumed that the cost-saving potential of shared PV can be further increased for ECs between multiple buildings. The market diffusion of ECs and PV sharing concepts will not only depend on the legal and regulatory framework, but especially on the profitability of such conc. Efforts to increase the share of renewable energy in the still predominantly centralised supply structure require decentralised alternatives. The microgrid is a framework that enables the integration of distributed energy resources [41,51,58] using local energy management systems [2,60,69,76]. Although microgrid concepts have existed for more than a decade, their application is still rare, due to limited incentives for implementation and multiple barriers [3,4,31]. The novel concept of local ECs can not only overcome some of these barriers but is also founded on an economic basis trying to maximise the synergy effects between different participants' load profiles and local renewable generation.Scientific literature that focuses on local energy sharing can be classified as follows based on the methodological approach to modelling:••Game theory•–Cooperative games.