Metamaterials are man‐made materials which get their properties from their structure rather than their chemical composition. Their mesostructure is specifically designed to create functionalities not found in nature. However, despite the broad variety of metamaterials developed in recent years, a straightforward procedure to design these complex materials with tailored properties has not yet been established. Here, the inverse design problem is tackled by introducing a general optimization tool to explore the range of material properties that can be achieved. Specifically, a stochastic optimization algorithm is applied and its applicability to disjoint problems is demonstrated, with a focus on tuning the buckling properties of mechanical metamaterials, including experimental verification of the predictions. Besides this problem, this algorithm can be applied to a large variety of systems that, because of their complexity, would be challenging otherwise. Potential applications range from the design of optomechanical resonators, acoustic band gap materials, to dielectric metasurfaces.