We propose a grating-based spatial differentiator to process a synthetic three-dimensional optical field, where several conventional two-dimensional optical images are stacked at multiple wavelengths. The device simultaneously enables both spatial differentiation and demultiplexing during light diffraction. We show the spatial differentiation resulting from coupling and interference of spatial modes and derive the theoretical condition for spatial differentiation based on spatial coupled-mode theory. We numerically investigate field transformation during diffraction and demonstrate spatial differentiation with image processing of edge detection for a synthetic three-dimensional optical field, where four images are stored at different wavelengths.