This paper presents a flexible method for designing a bandpass filter (BPF) using pixel structure and genetic algorithm (GA) optimization. The pixel structure is made up of a grid of metallic microstrip stubs, and the GA is utilized to determine the connections between these stubs. The pixel structure enables the construction of step impedance and shunt branches, which are used to design a traditional BPF. To enhance the design freedom, one side of the discrete grids is connected to the ground via metallic holes. For verification, a BPF was designed, simulated, and measured. The experimental results showed that the 10 dB return loss bandwidth ranges from 1.1 to 1.9 GHz and the insertion loss is approximately 2.5 dB. There is good agreement between the calculation, EM simulation, and measurement results. The proposed GA-based design method offers significant advantages in terms of one-time EM simulation, feasibility, and labor time savings, making it more convenient than the traditional design method.