Shape-programmable matter is a class of active materials whose geometry can be controlled to potentially achieve mechanical functionalities beyond those of traditional machines. Among these materials, magnetically actuated matter is particularly promising for achieving complex time-varying shapes at small scale (overall dimensions smaller than 1 cm). However, previous work can only program these materials for limited applications, as they rely solely on human intuition to approximate the required magnetization profile and actuating magnetic fields for their materials. Here, we propose a universal programming methodology that can automatically generate the required magnetization profile and actuating fields for soft matter to achieve new time-varying shapes. The universality of the proposed method can therefore inspire a vast number of miniature soft devices that are critical in robotics, smart engineering surfaces and materials, and biomedical devices. Our proposed method includes theoretical formulations, computational strategies, and fabrication procedures for programming magnetic soft matter. The presented theory and computational method are universal for programming 2D or 3D time-varying shapes, whereas the fabrication technique is generic only for creating planar beams. Based on the proposed programming method, we created a jellyfish-like robot, a spermatozoid-like undulating swimmer, and an artificial cilium that could mimic the complex beating patterns of its biological counterpart.programmable matter | multifunctional materials | soft robots | magnetic actuation | miniature devices S hape-programmable matter refers to active materials that can be controlled by heat (1-5), light (6, 7), chemicals (8-13), pressure (14, 15), electric fields (16, 17), or magnetic fields (18-33) to generate desired folding or bending. As these materials can reshape their geometries to achieve desired time-varying shapes, they have the potential to create mechanical functionalities beyond those of traditional machines (1, 15). The functionalities of shape-programmable materials are especially appealing for miniature devices whose overall dimensions are smaller than 1 cm as these materials could significantly augment their locomotion and manipulation capabilities. The development of highly functional miniature devices is enticing because, despite having only simple rigid-body motions (34-36) and gripping capabilities (37), existing miniature devices have already been used across a wide range of applications pertaining to microfluidics (38, 39), microfactories (40, 41), bioengineering (42, 43), and health care (35, 44).Among shape-programmable matter, the magnetically actuated materials are particularly promising for creating complex timevarying shapes at small scales because their control inputs, in the form of magnetic fields, can be specified not only in magnitude but also in their direction and spatial gradients. Furthermore, as they can be fabricated with a continuum magnetization profile, m, along their bodies, these magne...