Decentralized production of renewable electricity is steadily growing in the European Union. Solar and wind energy power plants are increasingly installed for self-consumption both by households and enterprises and these renewable energy installations could play an important role in the transition towards climate neutrality by 2050. All European Union's member states are required to develop national legal framework to allow energy communities to actively participate in the energy market and to further incentivize the usage of renewable energy. The aim of this study was to research the potential of energy communities in Latvian electricity market considering the developing legal framework and electricity demand and capacity conditions in Latvia. Research showed that currently the planned legislation in Latvia provides a good basic mechanism for energy communities and electricity sharing as well as peer-to-peer trade without harsh restrictions. Considering the future electricity deficit in Latvia, energy communities have a good potential, but further detailed requirements still must be developed in order to ensure the security of electricity grid.