The spice powder clumps together because it has been exposed to moisture.
Carbohydrates or proteins in the spice dissolve a small amount, becoming sticky, causing the granules to stick together.
To prevent this, keep your spices quite dry: If you buy in bulk, consider transferring some to a "currently being used" container, and leaving the rest away from the stove with its steam, and any other sources of moisture, well sealed against the humidity (and oxygen) in the air.
This will protect the bulk of your supply, even if the working container gets a little clumpy.
Use good quality, air tight containers for your spices.
I like to buy mine from the same vendor I buy spices from, but of course there are a myriad of options.
Add a food safe desiccation packet to the container.
I use the first method two methods, and have only had clumping in very old working spice jars that probably should have been discarded for having lost their flavor over time anyway.
Often, the clumps are quite fragile--banging the container on the counter a few times will often free up a bit, but it's a mechanical process.
The fork twisting is a good method to free up some for use.
As nicoleets hinted at, if your spice is clumpy, it is a sign that it has been exposed to the environment, and water and air have gotten in.
It may have also declined in flavor.
I wanted to add the "put some rice in the container" method, as one might for sugar or salt, but I cannot find any easily accessible evidence if this is a myth or if it really works.
After all, why should the rice be more likely to absorb water than the spice itself, when the spice has far more exposed surface area?
cooking.stackexchange.com/users/14401/SAJ14SAJ
So, there are a few reasons spices lump like that.
Mostly because they have been exposed to "the elements" of your kitchen.
Either moisture, too much heat, etc.
For instance if you shake your spice dispensers over a hot pan the steam will get in and clump the remaining portion.
You may want to consider getting smaller containers of spices to avoid their shelf life being shortened by exposure (while I know those bulk ones seems so appealing in the long run
it hurts more than helps), mixing your spices in a separate bowl before cooking so as not to keep the containers out/open for extended periods of time, sealing them in air tight containers when you're not using them (this may require getting rid of the containers they come in), and making sure they are kept in cool dry areas.
Dried spices also tend to start losing flavor fairly quickly (the type of spice and how it's dried will determine the "rate of decaying flavor").
Not that they're bad and there's no food safety issue it just might not taste as you would expect.
I've heard some speak about freezing spices to keep them longer, but I've never seen the science behind it
so I can't be sure.
cooking.stackexchange.com/users/14918/colejkeene
Try adding dried beans to the spices.
It works the same as adding rice to salt.
The dried beans are big enough to not pass through the holes in the large spice jars.
cooking.stackexchange.com/users/22582/user22582
Having had the hardening of garlic granules problem for some time and tried all the other additives like rice and beans etc., without success, I finally came up with this solution and has worked well for me for the past 4 months.
Remove the top from an empty tube of Vitamin effervescent tablets.
With a sharp knife (I used a scalpel) cut off the soft spring close to the top rim.
Next carefully cut down the side of the silica gel capsule to remove the top rim.
Discard the spring and rim.
Ensure the little cartridge is clean.
Reconstitute the spice powder and break up any lumps etc.
Pop the little cartridge into the spice container.....
Job done.
Happy sprinkling.
I have step by step pictures, send me your email address
and I happily send to anyone that wants them.
cooking.stackexchange.com/users/36114/un1corn
If you're just a simple person, and not a pro/chef who needs a bulk solution, just put it in the freezer.
As you can see in my video , I've had my onion/garlic powder in my freezer for at least 6 months.
I live in an hot and humid environment so storage even in dry cupboards tends to be a problem.
I also find those rice/bean things kinda tricky.
cooking.stackexchange.com/users/53779/Aaron Loy
I notice that sometimes, some of my spices become one hard block. I have this especially with my garlic powder, in a smaller degree with my chili powder (that contains the same garlic powder). I'm pretty sure it can happen to other spices as well.  Is there something I can do to prevent this? Is there a different solution for when it happens, other than putting in a fork and twisting? Why does this happen?
How can I prevent spices from lumping together?
cooking.stackexchange.com
<spices><garlic><consistency>
cooking.stackexchange.com/questions/32150
cooking.stackexchange.com/users/4580/Mien
This is a sign that the spices have been exposed to moisture either during storage or when shaking over a pan. Use good quality containers protected from cooking steam, and consider adding dried beans or a food-safe desiccation packet to the containers. Spice powder clumps together when exposed to moisture. Keep in an air tight container. You can also try adding a food safe desiccation packet.
Spice powder clumps together if it is exposed to moisture. Keep spices in air tight containers and avoid shaking over a pan with steam. Try adding dried beans or add a food safe desiccation packet.