Engineering quantum states of light is at the basis of many quantum technologies such as quantum cryptography, teleportation, or metrology among others. Though, single photons can be generated in many scenarios, the efficient and reliable generation of complex single-mode multiphoton states is still a longstanding goal in the field, as current methods either suffer from low fidelities or small probabilities. Here we discuss several protocols which harness the strong and long-range atomic interactions induced by waveguide QED to efficiently load excitations in a collection of atoms, which can then be triggered to produce the desired multiphoton state. In order to boost the success probability and fidelity of each excitation process, atoms are used to both generate the excitations in the rest, as well as to herald the successful generation. Furthermore, to overcome the exponential scaling of the probability of success with the number of excitations, we design a protocol to merge excitations that are present in different internal atomic levels with a polynomial scaling. DOI: 10.1103/PhysRevLett.118.213601 On-demand generation of optical propagating photons is at the basis of many applications in quantum information science, including multipartite teleportation [1], quantum repeaters [2], cryptography [3,4], and metrology [5]. While single photons are routinely produced in different experimental setups [6], e.g., by using natural or artificial atoms coupled to cavities or waveguides [7][8][9][10][11][12], single-mode multiphoton states are much harder to generate [13]. Current methods are limited by either exponentially small success probabilities or low fidelities. The enhancement of light-matter interactions provided by quantum nanophotonics opens up new avenues to create high-fidelity multiphoton states. For example, m quantum emitters can be strongly coupled to structured waveguides, which show large Purcell factors, P 1D , so that m atomic excitations can be mapped to a waveguide mode with an error (or infidelity, I m ) scaling as m=P 1D . However, the resulting state is not a single mode, but a complex entangled state of several modes [14], so that it cannot be directly used for quantum information purposes. Single-mode multiphoton states can be created by storing m collective excitations in N ≫ m atoms, which are then mapped to a photonic state of the waveguide. While the latter process can be achieved with very low infidelity, scaling as m 2 =ðNP 1D Þ [14,15], present schemes for the first part scale like I m ∝ m= ffiffiffiffiffiffiffiffi P 1D p [14], as they still do not fully exploit the strong coupling to the waveguide nor collective effects. This ultimately limits the fidelity of the whole procedure.In this work we show how to overcome this limitation with new schemes for the heralded generation of m collective excitations in N ≫ m atoms coupled to a waveguide. The idea is to use the atoms to both create the excitations one by one, and to herald the success of the process. In this way, arbitrarily sma...