This research proposes a methodology for the optimal location and sizing of reactive compensation in an electrical transmission system through a deep neural network (DNN) by considering the smallest cost for compensation. An electrical power system (EPS) is subjected to unexpected increases in loads which are physically translated as an increment of users in the EPS. This phenomenon decreases voltage profiles in the whole system which also decreases the EPS’s reliability. One strategy to face this problem is reactive compensation; however, finding the optimal location and sizing of this compensation is not an easy task. Different algorithms and techniques such as genetic algorithms and non-linear programming have been used to find an optimal solution for this problem; however, these techniques generally need big processing power and the processing time is usually considerable. That being stated, this paper’s methodology aims to improve the voltage profile in the whole transmission system under scenarios in which a PQ load is randomly connected to any busbar of the system. The optimal location of sizing of reactive compensation will be found through a DNN which is capable of a relatively small processing time. The methodology is tested in three case studies, IEEE 14, 30 and 118 busbar transmission systems. In each of these systems, a brute force algorithm (BFA) is implemented by connecting a PQ load composed of 80% active power and 20% reactive power (which varies from 1 MW to 100 MW) to every busbar, for each scenario, reactive compensation (which varies from 10 Mvar to 300 Mvar) is connected to every busbar. Then power flows are generated for each case and by selecting the scenario which is closest to 90% of the original voltage profiles, the optimal scenario is selected and overcompensation (which would increase cost) is avoided. Through the BFA, the DNN is trained by selecting 70% of the generated data as training data and the other 30% is used as test data. Finally, the DNN is capable of achieving a 100% accuracy for location (in all three case studies when compared with BFA) and objective deviation has a difference of 3.18%, 7.43% and 0% for the IEEE 14, 30 and 118 busbar systems, respectively (when compared with the BFA). With this methodology, it is possible to find the optimal location and sizing of reactive compensation for any transmission system under any PQ load increment, with almost no processing time (with the DNN trained, the algorithm takes seconds to find the optimal solution).