You can buy hat boxes.
Or if they are special hats display them along a wall.
I would hang them from an over the door hanger or peg rail or keep the nestled inside each other (to keep shape) and stored in a canvas bin in the closet.
I have hooks hanging on the wall in my closet and I hand all my hats from the hooks. They stay nice and I can see each one.
Fine millinery can be stacked using crushed tissue paper between each hat.
Baseball type caps can be folded in from the back and lined up, one inside the other, by color. Woolen and fur hats should be in moth proof containers, with an anti dessicant pack, as needed to reduce moisture levels.
Decorative hat boxes! Functional and they look pretty!