We present Morpho, an extensible programmable environment that uses finite elements for shape optimization in soft matter. Given an energy functional that incorporates physical boundaries and effects such as elasticity and electromagnetism, together with additional constraints to be satisfied, Morpho predicts the optimized shape and structure adopted by the material.