Piezoelectric materials can convert mechanical energy into electrical energy, and piezoelectric devices made of a variety of inorganic materials and organic polymers have been demonstrated. However, synthesizing such materials often requires toxic starting compounds, harsh conditions and/or complex procedures. Previously, it was shown that hierarchically organized natural materials such as bones, collagen fibrils and peptide nanotubes can display piezoelectric properties. Here, we demonstrate that the piezoelectric and liquid-crystalline properties of M13 bacteriophage (phage) can be used to generate electrical energy. Using piezoresponse force microscopy, we characterize the structure-dependent piezoelectric properties of the phage at the molecular level. We then show that self-assembled thin films of phage can exhibit piezoelectric strengths of up to 7.8 pm V-1. We also demonstrate that it is possible to modulate the dipole strength of the phage, hence tuning the piezoelectric response, by genetically engineering the major coat proteins of the phage. Finally, we develop a phage-based piezoelectric generator that produces up to 6 nA of current and 400 mV of potential and use it to operate a liquid-crystal display. Because biotechnology techniques enable large-scale production of genetically modified phages, phage-based piezoelectric materials potentially offer a simple and environmentally friendly approach to piezoelectric energy generation.