A theoretical study of the structural, electronic and optical properties of KMgF₃ is presented using the full-potential linearized augmented plane wave method (FP-LAPW). In this approach, the local density approximation was used for the exchange-correlation potentials. First, we present the main features of the structural and electronic properties of this compound, where the electronic band structure shows that the fundamental energy gap is indirect. The contribution of the different bands was analysed from the total and partial density of states curves. The different interband transitions have been determined from the imaginary part of the dielectric function. The results are compared with previous calculations and with experimental measurements. The present work also deals with the behaviour of electronic properties, namely, the energy band gaps, and the valence bandwidth of KMgF₃ subject of hydrostatic pressures up to 30 GPa