Circuit quantum electrodynamics (QED) employs superconducting microwave resonators as quantum buses. In circuit QED with semiconductor quantum-dot-based qubits, increasing the resonator impedance is desirable as it enhances the coupling to the typically small charge dipole moment of these qubits. However, the gate electrodes necessary to form quantum dots in the vicinity of a resonator inadvertently lead to a parasitic port through which microwave photons can leak, thereby reducing the quality factor of the resonator. This is particularly the case for high-impedance resonators, as the ratio of their total capacitance over the parasitic port capacitance is smaller, leading to larger microwave leakage than for 50-ω resonators. Here, we introduce an implementation of on-chip filters to suppress the microwave leakage. The filters comprise a high-kinetic-inductance nanowire inductor and a thin-film capacitor. The filter has a small footprint and can be placed close to the resonator, confining microwaves to a small area of the chip. The inductance and capacitance of the filter elements can be varied over a wider range of values than their typical spiral inductor and interdigitated capacitor counterparts. We demonstrate that the total linewidth of a 6.4 GHz and approximately 3-kω resonator can be improved down to 540 kHz using these filters.