A method to create sub-micron changes of the chemical composition of silica based optical fibers is reviewed. The method is used to create thermally stable refractive index structures, Fiber Bragg gratings, which can be used e.g. as sensors operating at very high temperatures. The method is based on UV induced chemical reactions of the silica glass with in-diffused molecular hydrogen. A change in the chemical composition is attained after thermal treatment, and the mechanism is attributed to diffusion of hydrogen compounds within the glass.