Abstract Graphitization (1400 °C–2200 °C) of polyacrylonitrile (PAN)-based carbon fiber in a small furnace with direct electric heating by Joule effect was studied in situ by small angle X-ray scattering (SAXS) with X-ray synchrotron radiation. The two-dimensional SAXS images display an anisotropic shape indicating the existence of needle-like or elongated ellipsoid-shaped pores oriented along the fiber axis. The one-dimensional scattering curves display obvious positive deviation from Porod's law indicating the existence of micro-fluctuation of electron density in the skeleton of the fiber which give rise to additional scattering. After correcting the deviation from Porod's law, the pure pore scattering was derived, and the pore structure parameters were computed. The results show that with increasing temperature the orientation angle decreases whereas the orientation degree increases. The long axis decreases whereas the short axis increases leading to a lower axial ratio. The size distribution becomes broader and there is a maximum value of porosity and specific surface area at 1900 °C. The change of pore structure in the fiber with temperatures can be approximately divided into two stages corresponding to denitrification condensation (1400 °C–1900 °C) and structure rearrangement (1900 °C–2200 °C) during graphitization, respectively. The corresponding mechanism was analyzed.