Optically heated fiber Bragg gratings due to the absorption over the fiber core in rare-earth doped fibers are experimentally demonstrated. Bragg wavelength variations with pump power are measured for different fibers. We found that the Er/Yb-codoped fiber presents the strongest thermal effect, due to the high absorption. A maximum wavelength shift of 1.34 nm can be obtained when the 980 nm pump power is 358 mW under room temperature, suggesting the fiber is heated up to over 100 °C. Furthermore, the thermal effect is enhanced by pumping the surrounding air to close to vacuum. A wavelength shift of 1.69 nm is attained, due to the weakened ability of heat transfer at the silica-air interface. The optical heating presents a very short response time and can found applications in low temperature circumstances.