We have developed a software MagGene to predict magnetic structures by using genetic algorithm. Starting from an atom structure, MagGene repeatedly generates new magnetic structures and calls first-principles calculation engine to get the most stable structure. This software is applicable to both collinear and noncollinear systems. It is particularly convenient for predicting the magnetic structures of atomic systems with strong spin-orbit couplings and/or strong spin frustrations.