The chemical reactions and pathways resulting in the formation of purine nucleobases, one of the two classes of nitrogen-containing ring compounds found in DNA and RNA, which include adenine and guanine.