This work investigates the electronic structures, defect formation energies and optical properties of charged oxygen vacancy and oxygen interstitial in KH2PO4 (KDP) crystals by First-principles. We find that the lattice distortion caused by VO is greater than that of Oi. For the neutral VO in the ferroelectric (FE) phase, the bond between H and O breaks and re-bonded in VO· system. In VO·· (The superscript represents the charged state, the ‘´’ represents negative charges and ‘·’ represents positive charges), the (PO3)−1 drags the neighboring (PO4)−3 over and bonded with the same O ion. Then it generates a large interstitial position in the structure, which makes it easy to introduce impurity interstitial. Small polaron makes electrons tend to be localized on two or three oxygen ions around the oxygen vacancy. Oxygen defects introduce new defect states in the band gap, which are mainly composed of the p-orbital of O ions. The defect formation energy of VO in two phases and Oi in the FE phase shows negative-U characteristics. Optical spectra indicate that the 467 nm luminescence band originates from the Oi′. The absorption band range from 163 nm to 246 nm is caused by vacancy and range from 212 nm to 428 nm by interstitial. The 200 nm and 285 nm absorption peaks originate from the F-centers (theVO capturing two electrons) and Oi′, respectively. We predict that oxygen defects will introduce additional UV absorption peaks such as 258 nm, 203 nm, 184 nm, and 163 nm, which significantly affect the optical threshold of KDP crystals.