Significance Hydrogels are extensively used for cell culture, tissue engineering, and flexible electronics. In all of these applications, mechanical properties of hydrogels play an important role. Although tremendous studies have been devoted to optimizing the stiffness, strain, toughness, and dynamic mechanical response, the mechanical homogeneity of hydrogels has rarely been considered. By developing a general strategy to control the mechanical homogeneity of hydrogels, here we show that nanoscale variation in matrix stiffness can considerably affect the lineage specification of human embryonic stem cells. Inhomogeneous hydrogels suppress mechanotransduction and facilitate stemness maintenance, while homogenous hydrogels promote mechanotransduction and osteogenic differentiation. Therefore, engineering hydrogels with controllable and well-defined nanoscale homogeneity may have considerable implications in stem cell culture and regenerative medicine.