You need a bladed spice grinder, also branded as bladed coffee grinders.
To have a consistent result, sift the result.
I would use my mortar and pestle.
I have been thru many coffee bean grinders. I still use the mortar and pestle I bought in 1992. It is easy to get the spices out. It is easy to clean. It is easy to control the grind. If spices are wet, or greasy, it works. It was cheap.
It is old school.
Not long ago I managed to do that with just a regular blender. Put chili flakes in and whirl until powdered. Do not remove the lid before chili powder settles. Then gently sift for very consistent result.
I wouldn't really recommend using a coffee grinder because that would bring too much heat in.
If you want to turn flakes to powder, you need this: