Integrated microwave photonics, an emerging technology combining radio frequency (RF) engineering and integrated photonics, has great potential to be adopted for wideband analog processing applications. However, it has been a challenge to provide photonic integrated circuits with equal levels of function flexibility as compared with their electronic counterparts. Here, we introduce a disruptive approach to tackle this need, which is analogous to an electronic field-programmable gate array. We use a grid of tunable Mach–Zehnder couplers interconnected in a two-dimensional mesh network, each working as a photonic processing unit. Such a device is able to be programmed into many different circuit topologies and thereby provide a diversity of functions. This paper provides, to the best of our knowledge, the first ever demonstration of this concept and shows that a programmable chip with a free spectral range of 14 GHz enables RF filters featuring continuous, over-two-octave frequency coverage, i.e., 1.6–6 GHz, and variable passband shaping ranging from a 55 dB extinction notch filter to a 1.6 GHz bandwidth flat-top filter.