Hydrogen with ultrahigh density confined in single-walled carbon nanotubes (SWCNTs) was investigated using density functional theory (DFT) and first principles molecular dynamics simulations (MDSs). Hydrogen atoms injected in to the cages of the SWCNTs via atomic collisions gradually form solid H2 molecular lattice with a characteristic of spiral multi-strands structure. The concentration of H2 confined in the SWCNTs can be as high as ~ 1.77×1023H2 /cm3, and the pressure between the H2 lattice and the wall of the SWCNT can be as high as ~ 77 GPa. When the system was heated to temperature higher than 700K, a solid-liquid phase transition was observed. When temperature rose to 1000K, a few H2 molecules dissociated forming a mixed liquid of H atoms, H2 molecules, and hydrogen trimers. Electron states near the Fermi level were appeared, which were attributed to the H atoms and the trimers. The electronic properties of the quasi-one-dimensional hydrogen confined in the SWNTs were thus substantially changed.