Self-assembly of complex structures is common in nature. Self-assembly principles provide a promising way to fabricate three-dimensional, micro- or millimeter scale devices. In the present paper, we present a generalized analytical study of the self-folding of thin plates into deterministic 3D shapes through fluid–solid interactions. Based on the beam theory, a mechanics model is developed, incorporating the two competing components—a capillary force promoting folding and the bending rigidity of the foil that resists folding into a 3D structure. Through an equivalence argument of thin foils of different geometry, an effective folding parameter, which uniquely characterizes the driving force for folding, has been identified. A criterion for spontaneous folding of any shaped 2D patterned foil based on the effective folding parameter is thus established. The model predictions show excellent agreement with experimental measurements made on a variety of materials, indicating that the assumptions used in the analysis arevalid.