  Gamma-ray Bursts (GRBs) are the most powerful explosions known, capable of
outshining the rest of gamma-ray sky during their short-lived prompt emission.
Their cosmological nature makes them the best tool to explore the final stages
in the lives of very massive stars up to the highest redshifts. Furthermore,
studying the emission from their low-energy counterparts (optical and infrared)
via rapid spectroscopy, we have been able to pin down the exact location of the
most distant galaxies as well as placing stringent constraints on their host
galaxies and intervening systems at low and high-redshift (e.g. metallicity and
neutral hydrogen fraction). In fact, each GRB spectrum contains absorption
features imprinted by metals in the host interstellar medium (ISM) as well as
the intervening intergalactic medium (IGM) along the line of sight. In this
chapter we summarize the progress made using a large dataset of GRB spectra in
understanding the nature of both these absorbers and how GRBs can be used to
study the early Universe, in particular to measure the neutral hydrogen
fraction and the escape fraction of UV photons before and during the epoch of
re-ionization.
