Peptides have attracted considerable attention due to their biocompatibility, functional molecular recognition and unique biological and electronic properties. The strong piezoelectricity in diphenylalanine peptide expands its technological potential as a smart material. However, its random and unswitchable polarization has been the roadblock to fulfilling its potential and hence the demonstration of a piezoelectric device remains lacking. Here we show the control of polarization with an electric field applied during the peptide self-assembly process. Uniform polarization is obtained in two opposite directions with an effective piezoelectric constant d33 reaching 17.9 pm V-1. We demonstrate the power generation with a peptide-based power generator that produces an open-circuit voltage of 1.4 V and a power density of 3.3 nW cm-2. Devices enabled by peptides with controlled piezoelectricity provide a renewable and biocompatible energy source for biomedical applications and open up a portal to the next generation of multi-functional electronics compatible with human tissue.