I show that maximally helical hypermagnetic fields produced during pseudoscalar inflation can generate the observed baryon asymmetry of the universe via the B+L anomaly in the Standard Model. Most of the parameter space of pseudoscalar inflation that explains the cosmological data leads to baryon overproduction, hence the models of natural inflation are constrained. I also point out a connection between the baryon number and topology of the relic magnetic fields.