This study reports on the synthesis of hafnium diboride (HfB2)-based nanofibers via electrospinning of polyhafnoxanesal (PHO)-based solution followed by pyrolyzing hafnium-boron containing polyvinylpyrrolidone precursor fibers by a moderate heat treatment at 1500 degrees C under argon atmosphere. The influence of the molar ratios of C/Hf and B/Hf in preceramic polymer method is investigated on the final phase of HfB2-based nanofibers. Structural, thermal, microstructural, and physical properties of the hafnium-based fibers are evaluated using Fourier transform infrared spectra (FTIR), thermogravimetry and differential scanning calorimetry (TG/DSC), X-ray diffractometer (XRD), high-temperature X-ray diffraction (HT-XRD), field-emission scanning electron microscope/energy-dispersive spectrometer (FE-SEM/EDS), and Brunauer-Emmett-Teller (BET). The results unveiled that the acidic pH was the optimal condition needed for obtaining the single phase of HfB2 nanofibers. The precursor fibers with the stoichiometric ratio of 1:4:5 of Hf:B:C prepared under the acidic conditions converted into pure HfB2 nanofibers having rough and porous surface after pyrolysis at 1500 degrees C for 2 hour in argon, whereas HfB2-HfC composite nanofibers with smooth surface were produced in the neutral conditions. The HfB2 nanofibers with a mean diameter of similar to 100 nm prepared under the acidic conditions showed a higher specific surface area compared to HfB2-HfC composite nanofibers with a diameter of similar to 121 nm derived in the neutral conditions.