Dielectrons are unique tools to study the space-time evolution of the hot and dense QCD matter created in ultra-relativistic heavy-ion collisions.
They are produced by a variety of processes during all stages of the collision with negligible final-state interactions.
Thermal radiation from the hadronic phase contributes to the spectrum at low invariant mass ($m_{\rm ee}$),
while thermal radiation from the quark-gluon plasma (QGP) at larger $m_{\rm ee}$ carries information about the early temperature of the medium.
The latter is dominated by a large background from semileptonic decays of correlated heavy-flavor hadrons affected by parton energy loss and flow in the medium.
In the quasi-real virtual photon region where $m_{\rm ee} \ll p_{\rm T,ee}$, the direct photon fraction can be extracted from the $m_{\rm ee}$ spectrum as a function of transverse momentum ($p_{\rm T,ee}$).
In pp collisions, such measurement serves as a fundamental test for perturbative QCD calculations and as a baseline for the studies in heavy-ion collisions.
We discuss the latest ALICE results on dielectron production in Pb--Pb and pp collisions at $\sqrt{s_{\rm NN}}$ = 5.02 TeV and $\sqrt{s}$ = 13 TeV, respectively.
The results are compared with the expected dielectron yield from known hadronic sources and predictions for thermal radiation from the medium.
The production of direct photons in the different colliding systems including high-multiplicity pp collisions is also reported.