By using ab initio molecular dynamical simulation, the local atomic and electronic environment around B atoms in ternary Fe–Nb–B alloys was investigated in details. We find that, with a large amount of B addition, abundant direct B–B bonds promote the propagation of prisms-like B-centered <0 3 6 0> polyhedron instead of antiprisms-like <0 2 8 0> polyhedron in Fe–Nb–B system. <0 3 6 0> polyhedron has a similar atomic configuration as the only B-centered <0 5 4 0> polyhedron in metastable Fe23B6 phase. It causes that the Fe23B6 phase rather than simple bcc α-Fe phase forms as the primary crystallization phase in Fe-rich system via the direct B–B bonding. Such a strong B–B covalent bonding as indicated by an obvious pseudogap in the density of states of p-orbital of B in the vicinity of Fermi level and the high charge density distribution between B–B bonds, also benefits the formation of skeleton networks by the vertex, edge and face sharing of <0 5 4 0> polyhedra in Fe23B6 phase. These complex crystallization modes and directional bonding structures introduced by the covalent effect of metalloid B are the structural origin for the excellent glass-forming ability of B-rich systems. In addition, the B alloying also enhances the average magnetic moments of Fe. However, the negative spin polarization of both Nb and B eventually causes a worse magnetism. Thus, for maintaining a high magnetic performance and formability in Fe–Nb–B system, the proper metalloid addition should be considered for material design. Our studies help us better understand the structural origin for the formation of metallic glass and offer a potential strategy for designing ferromagnetic glassy alloys with the outstanding formability as well as magnetism.