Solar observations clearly link the observed emission of high-energy radiation (X-rays, EUV) in the corona to the presence of a magnetic field, with a stronger activity where the magnetic field intensity is higher. But the low collisionality of the hot coronal plasma implies that diffusion of magnetic fields and the dissipation of its energy are negligible at large scales. Thus, in order to explain the observed activity in terms of dissipation of magnetic energy, the magnetic field must be structured at very small scales. Photospheric convection injects energy in the corona shuffling the footpoints of magnetic field lines. As pointed out first by Parker (1972) the relaxation of the resulting magnetic field should indeed lead to the formation of strong current sheets, where energy can be dissipated(nanoflares), and magnetic reconnection occur. I will discuss under which condition current sheets form in magnetic topologies relevant to the solar corona, its physical properties, bearing on coronal heating and connection with magnetohydrodynamic turbulence. Furthermore X-ray emission is also observed in all late-type main-sequence stars that, as the Sun, exhibit a convective envelope, a dynamo, and a magnetized corona. The results shown for the solar case are extended to stellar coronae for which the values of magnetic field intensity, photospheric velocity, temporal and spatial correlation scales differ considerably. I will also discuss so-called interchange reconnection, i.e., reconnection between open and closed field lines, a process that is supposed to play a prime role in the formation of the slow component of the solar wind. Previous modeling has mostly assumed interchange to occur in correspondence of magnetic neutral points (where B=0), thus strongly restricting the locations where it can occur. Recent results suggest that current sheets form continuously at the boundary between open and closed regions (coronal holes and loops) where the magnetic field does not vanish, allowing interchange reconnection to take place everywhere along the loop-coronal-hole boundary as indicated by new observations. Finally I will discuss future directions of this research.