Atomic chains and crystal of iodine were successfully generated in a controlled manner inside single-walled carbon nanotubes (SWNTs). The structure is strongly dependent on the diameter of SWNTs; the single, double, and triple helical structures became quite stable when the diameter of SWNTs matches the certain size. More than three chains of iodine are not very stable, and they often crystallize inside the carbon nanotube when the diameter is larger than 1.45 nm. The crystallization or phase transition in a confined nanospace is thus directly observed, and there is indeed a critical size of the hollow nanospace for the stable formation of the atomic chains of iodine.