The increasing cost of electricity generation using fossil fuels has increased the growth in renewable energy resources (RER). In the context of commercial buildings., the electricity bill comprises energy usage in kWh and peak demand in kW. To reduce peak demand and thus electricity costs., a hybrid solar photovoltaic (PV) and battery energy storage system (BES) can be used to replace grid energy requirements. Yet., despite their attractiveness., PV and BES introduce another dimension of complexity. Therefore., careful selection of PV and BES capacity based on load demand is required to reduce total investment costs and the monthly electricity bill without sacrificing reliability. The PV -BES system is developed for a 20-year operating period using a single-objective optimization approach to reduce the objective function., which is the total net present cost (NPC). In this paper., a PV -BES energy management system with peak shaving is designed using real-time load patterns., solar insolation., ambient temperature., Malaysian net energy metering (NEM)., and the limitation of maximum exporting power supplied to the grid. Based on a scenario where PV capacity is constrained by the availability of rooftop space and NEM rates., the optimal PV and BES capacities are obtained for the analyzed system. The case study demonstrates that the average monthly cost of electricity bills could be reduced by 22.27%. It also revealed that the annual energy consumption and peak demand could be reduced by 22.62% and 15.85%., respectively., with additional benefits by selling 6177.782 kWh of electricity to the grid. The proposed method could be useful for sizing the PV-BES system for any Malaysian commercial building.