  We review the results in our recent works on the generation of strong
magnetic fields in compact stars driven by the parity violating electroweak
interactions between background fermions. The cases of a neutron star, a hybrid
star, and a quark star are considered. We formulate the system of kinetic
equations for the description of the spectra of the magnetic energy and the
magnetic helicity, as well as for the chiral imbalances. Turbulence effects,
which can be important for the evolution of small-scale magnetic field, are
also taken into account. We find the numerical solution of these equations in
case of large- and small-scale magnetic fields in quark matter. The
applications of the obtained results for the generation of large-scale magnetic
fields in magnetars and for the explanation of magnetar bursts are discussed.
