Abstract In this study, a finite‐element analysis of a varying‐width piezoelectric energy harvester (PEH) has been presented. A varying‐width piezoelectric energy harvester (cantilever type) has variation in the width at definite intervals along its length. To harvest the energy over the wide frequency range of environmental vibrations, nonlinearity is introduced in the stiffness by mean of two neodymium magnets. The width of the proposed varying‐width cantilever PEH is calculated using block pulse functions (BPFs). The objective of applying BPFs is to proximate a triangular PEH (with fixed base) into a proposed varying‐width PEH with three rectangular sections along length. The use of BPFs enable the use of rectangular patches of lead zirconate titanate (PZT‐5A). This leads to a reduction in cost as machining PZT at other than straight cuts results in an extensive increase in the production costs. The varying‐width piezoelectric cantilever beam is subjected to harmonic base excitations by applying a vertical acceleration of 0.2 g ( g =9.81 m s −2 ). Numerical study indicates that the bistable varying‐width PEH generates at least two times the average power than that generated by a bistable uniform‐width PEH for the same volume of piezoelectric material and for the same linear natural frequency. Furthermore, the bistable varying‐width PEH is optimized using a genetic algorithm technique to maximize the mean power density.