Programmable self-assembly of smart, digital, and structurally complex materials from simple components at size scales from the macro to the nano remains a long-standing goal of material science. Here, we introduce a platform based on magnetic encoding of information to drive programmable self-assembly that works across length scales. Our building blocks consist of panels with different patterns of magnetic dipoles that are capable of specific binding. Because the ratios of the different panel-binding energies are scale-invariant, this approach can, in principle, be applied down to the nanometer scale. Using a centimeter-sized version of these panels, we demonstrate 3 canonical hallmarks of assembly: controlled polymerization of individual building blocks; assembly of 1-dimensional strands made of panels connected by elastic backbones into secondary structures; and hierarchical assembly of 2-dimensional nets into 3-dimensional objects. We envision that magnetic encoding of assembly instructions into primary structures of panels, strands, and nets will lead to the formation of secondary and even tertiary structures that transmit information, act as mechanical elements, or function as machines on scales ranging from the nano to the macro.