In this study, our goal is to analyze the origin of magnetization in non magnetic cubic structure perovskite BaSnO3 doped with 2p-X (X=C, N) using the full potential linearized augmented plane wave (FP-LAPW) method based on density functional theory (DFT). For the exchange and correlation potential we have applied the generalized gradient approximation (GGA) and the GGA plus-modified Becke-Johnson potential (mBJ-GGA). The results show that BaSnO3 doped with C then with N and finally with C and N exhibit half-metallic ferromagnetism behavior with the integer magnetic moment of 1, 2 and 3 μB per cell respectively. The origin of the ferromagnetism that occurs within these compounds is mainly caused by the p-p hybridization between 2p-impurities and its neighboring oxygen atoms. These results allowed to conclude that doped perovskite could provide a new type of materials, called half-metallic for future spintronic devices.