Quantities up to 1/4 and 1/3rd of the compost pile have been recommended. [4] X Research source There are two main types of composting materials: “green” compost and “brown” compost. Coffee grounds are considered to be “green” compost along with other wet, nutrient rich materials. If you add a lot of coffee grounds to your compost, balance it out by adding some “brown” compost as well — dry, bulky materials like dry leaves, twigs, newspaper, straw, corn husks, sawdust, and so on. [5] X Research source Due to phytotoxins in the used coffee grounds, compost made with used coffee grounds may take 6 months to a year to mature and break down the phytotoxins. [6] X Research source

Coffee grounds are rich in: Nitrogen Magnesium Potassium Coffee grounds are not rich in: Phosphorous Calcium

It will have the same nutrient content as normal coffee grounds, so use it with caution if your plants don’t require nitrogen, potassium, etc.

It’s thought that this works because the caffeine in the coffee grounds hurts these pests. [9] X Research source