Phase transformations in crystalline materials are common in nature and often modify dramatically properties of materials. The ability to precisely control them with a high spatial precision represents a significant step forward in realizing new functionalities in confined dimensions. However, such control is extremely challenging particularly at the atomic scale due to the intricacies in governing thermodynamic conditions with a high spatial accuracy. Here, we apply focused electron beam of a scanning transmission electron microscope to irradiate SrNbO3.4 crystals and demonstrate a precise control of a phase transformation from layered SrNbO3.4 to perovskite SrNbO3 at the atomic scale. By purposely squeezing O atoms out of the vertex-sharing NbO6 octahedral slabs, their neighboring slabs zip together, resulting in a patterning of SrNbO3 nanopillars in SrNbO3.4 matrix. Such phase transformations can be spatially manipulated with an atomic precision, opening up a novel avenue for materials design and processing and also for advanced nanodevice fabrication.