  The Cosmic Background (CB) is defined as the isotropic diffuse radiation
field with extragalactic origin found across the electromagnetic spectrum.
Different astrophysical sources dominate the CB emission at different energies,
such as stars in the optical or active galactic nuclei in X-rays. Assuming that
dark matter consists of axions or axion-like particles with masses on the order
of electron volts or higher, we expect an additional contribution to the CB due
to their decay into two photons. Here, we model the CB between the optical and
X-ray regimes, and include the contribution of decaying axions. Through a
comparison with the most recent direct and indirect CB measurements, we
constrain the axion parameter space between masses $0.5\, \mathrm{eV}\, -
10^7\,\mathrm{eV}$ and improve previous limits on axion-photon coupling derived
from the CB by roughly an order of magnitude, also reaching the QCD band. We
further study the contribution of axions decaying in the Milky Way halo and
characterize the axion parameters that would explain the tentative excess CB
emission observed with the LORRI instrument on-board the New Horizons probe.
