Stimuli-responsive shape-shifting polymers1-3 have shown unique appeals in emerging applications including soft robotics4-7, medical devices8, aerospace structures9, and flexible electronics10. Their externally triggered shape-shifting behavior offers on-demand controllability essential for many device applications. Ironically, accessing external stimulation (e.g. heating or light) under realistic scenarios has become the biggest bottleneck for increasingly demanding applications such as implantable medical devices8. In contrast, autonomous shape-shifting polymers11,12 can operate in a trigger-free manner, but at the cost of losing the ability for active manipulation. Combining the attractive yet conflicting attributes (on-demand and autonomous) in one material is highly desirable. Here, we achieve this seemingly unrealistic goal with a 4D printable shape memory hydrogel that operates via spinodal decomposition, with its shape-shifting dominated by internal mass diffusion instead of thermal conduction for common shape memory polymers8-10,13. This allows the hydrogel to undergo fully autonomous shape transformation, critically with an on-demand programmable onset. The precisely controlled shape-shifting behavior without requiring any external stimulation markedly lowers the barrier for future device implementation.