Physical systems differing in their microscopic details often display strikingly similar behaviour when probed at macroscopic scales. Those universal properties, largely determining their physical characteristics, are revealed by the renormalization group (RG) procedure, which systematically retains ‘slow’ degrees of freedom and integrates out the rest. We demonstrate a machine-learning algorithm based on a model-independent, information-theoretic characterization of a real-space RG capable of identifying the relevant degrees of freedom and executing RG steps iteratively without any prior knowledge about the system. We apply it to classical statistical physics problems in 1 and 2D: we demonstrate RG flow and extract critical exponents. We also discuss the optimality of the procedure.