The composite cavity optomechanical system combining optical Fabry-Perot (F-P) cavities, particles, and micro/nano mechanical oscillators is becoming more significant in the researches and applications of the fundamental physics, quantum information processing, and precision measurement. Characterizing the mode field distribution of optical F-P cavity is significant prior to the application of optical F-P cavity. In this paper, we propose and demonstrate a method to measure the waist of an optical F-P cavity and to characterize the mode field distribution of the optical F-P cavity by using a nanofiber nondestructively. In experiment, a nanofiber is placed in the mode of the optical F-P cavity with a fineness of around 1500. The optical F-P cavity is composed of two mirrors each with high reflectivity of 99.8%. The radius of curvature of the each mirror is 50 mm. The cavity length is (
$ 80 \pm 4 $
) mm. The nanofiber is fabricated from a single-mode fiber by the flame-brush method. The nanofiber diameter is around 440 nm. The transmission spectra of the optical F-P cavity are measured by scanning the cavity length. The free spectrum ranges and the inner cavity losses can be obtained from the transmission spectra. First, the influence of the nanofiber on the optical F-P cavity fineness is investigated. The fineness as a function of nanofiber position along the radial direction of the optical F-P cavity is measured. The fineness caused by the nanofiber decreases to a minimum value of about 240. Second, it is investigated that the optical F-P cavity inner loss caused by the nanofiber as a function of the nanofiber position along the radial direction of the optical F-P cavity when the nanofiber is placed at the waist of the optical F-P cavity. The inner loss of the optical F-P cavity caused by the nanofiber is related to the intensity distribution of the optical F-P cavity mode field, which is predicted theoretically. Thus, by making the Gaussian fitting of the optical F-P cavity inner loss as a function of the nanofiber position, we can obtain a waist radius of the optical F-P cavity to be (
$ 72 \pm 1 $
) μm. This is in good agreement with the theoretical calculation. Finally, the mode field distribution of the optical F-P cavity along the cavity axis is characterized. This method can be used for precisely controlling the coupling between the particles on the surface of nanofiber and optical F-P cavity. Besides, this method provides a good platform for studying the hybrid optomechanical system combining cavities, photons and quantum emitters.