Modeling power electronic converters becomes even more important in systems such as microgrids. These models are very useful for dynamic interaction among converters and stability analysis. This paper proposes a black-box approach to obtain an equivalent switching model of open and closed loop converters. The information needed to apply this method is a general knowledge about the converter topology. Then, the parameters are identified by employing a combination of the particle swarm optimization and the genetic algorithm. The proposed approach is validated by means of detailed simulations and experimentally using a buck and a boost converter. The advantage of the approach is that, with just minimum information regarding converter topology, it is possible to obtain a very accurate switching model which inherently accounts for the nonlinearities caused by the switching nature of the converters, which is key for nonlinear stability analysis.