We demonstrate a fast image acquisition technique in the terahertz range via spectral encoding using a metasurface. The metasurface is composed of spatially varying units of mesh filters that exhibit bandpass features. Each mesh filter is arranged such that the centre frequencies of the mesh filters are proportional to their position within the metasurface, similar to a rainbow. For imaging, the object is placed in front of the rainbow metasurface, and the image is reconstructed by measuring the transmitted broadband THz pulses through both the metasurface and the object. The 1D image information regarding the object is linearly mapped into the spectrum of the transmitted wave of the rainbow metasurface. Thus, 2D images can be successfully reconstructed using simple 1D data acquisition processes.