Yes I add them to my compost heap they are rich in nitrogen but the also contain caffeine so be careful if using as a mulch direct onto the soil.
From Google
Using Coffee Grounds as Fertiliser
"Many of us will have dumped the cold remains of a forgotten coffee in a plant pot at some point, and then perhaps wondered if it was the wrong thing to do! But it turns out that coffee grounds contain a good amount of the essential nutrient nitrogen as well as some potassium and phosphorus, plus other micronutrients. The quantity and proportions of these nutrients varies, but coffee grounds can be used as a slow-release fertiliser.
To use coffee grounds as a fertiliser sprinkle them thinly onto your soil, or add them to your compost heap. Despite their colour, for the purposes of composting theyre a green, or nitrogen-rich organic material. Make sure to balance them with enough browns carbon-rich materials such as dried leaves, woody prunings or newspaper. Your compost heaps tiny munchers and gnawers will process and mix them effectively, so using coffee grounds in this way is widely accepted to be safe and beneficial.
Many vermicomposters say that their worms love coffee grounds, so small quantities could also regularly be added to a worm bin if you have one. Paper coffee filters can go in too."