Yes, you can compost spinach and other similar leafy greens like chard.
They rot down quickly in a compost heap – as a “green“, they’re are a good source of nitrogen.
If you’ve got a lot to get rid of, add them alongside “browns” (like newspaper, egg boxes or straw) to keep you compost balanced.