Random scattering media in the diffusive regime provide a long light path and multipath interference in a compact area, resulting in strong dispersive properties which can be used for on-chip compressive spectrometry. However the performance suffers from the low light transmission through the diffusive medium. It has been found that there exist ‘open channels’ such that light with certain wavefronts can pass through the medium with high transmission. Here we show that a scattering structure can be designed so that open channels match target input-output channels, in order to maximize transmission while keeping the dispersive properties typical of random media. Specifically, we use inverse design to generate a scattering structure where the open channels match the output waveguides at desired wavelengths. For a proof of concept, we propose a 1×10 multiplexer covering a band of 500nm in the mid-infrared spectrum, with a footprint of only 9.4μm×14.4μm. We also show that filters with nearly arbitrary spectral response can be designed, enabling a new degree of freedom in on-chip spectrometer design, and we investigate the ultimate resolution limits of these structures. The structures can also be designed based on a simple topology consisting of circular holes with diameters from 200nm to 700nm etched in a dielectric slab, making them highly suited for fabrication. With the help of compressive sensing, the proposed method represents an important tool in the quest towards integrated lab-on-a-chip spectroscopy.