Based on the first-principles and quasi-harmonic Debye model, the structure, electronic, optical and thermodynamic properties of XBeF3 (X = Na, K) crystals at 0 ∼ 30 GPa are systematically investigated for the first time. The lattice constant, elastic constants, and bulk modulus of NaBeF3 and KBeF3 crystals are calculated under zero temperature and zero pressure, which are consistent with the literature values. The studies of electronic properties show that the ultra-wide band gaps of NaBeF3 and KBeF3 crystals at 0 GPa are 7.096 eV and 7.720 eV, respectively. Their band gaps increase with increasing pressure, while their type is indirect without the influence of pressure. Besides, the band structure of XBeF3 crystals at 0 ∼ 30 GPa is calculated by HSE06 functional. The variation of the XBeF3 band gap calculated by the HSE06 function with pressure is consistent with the trend of GGA functional. Additionally, the optical properties including reflectivity, absorption coefficient, complex refractive index, dielectric function and conductivity of NaBeF3 and KBeF3 crystals from 0 to 30 GPa have been comprehensively investigated. Using the quasi-harmonic Debye model, the relative volume, expansion coefficient, Debye temperature and heat capacity effect with pressures and temperatures of NaBeF3 and KBeF3 at 0 ∼ 30 GPa are also researched. The Debye temperatures of NaBeF3 and KBeF3 at 300 K are calculated to be 656.38 K and 602.6 K respectively. At relatively high temperature, the heat capacity at constant volume gradually approaches the Dulong-Petit limit. The results in this paper show that NaBeF3 and KBeF3 crystals may be used in the fields of lens materials and window materials in the deep ultraviolet range. Additionally, the ultra-wide band gap characteristics of NaBeF3 and KBeF3 enable them to be useful as highly insulating layers and high-voltage capacitors.