Purpose - The main purpose of this study is to provide an effective sizing method and an optimal peak shaving strategy for an energy storage system to reduce the electrical peak demand of the customers. A cost-savings analytical tool is developed to provide a quick rule-of-thumb for customers to choose an appropriate size of energy storage for various tariff schemes. Design/methodology/approach - A novel sizing method is proposed to obtain the optimum size of energy storage for commercial and industrial customers based on their historical load profile. An algorithm is developed to determine the threshold level for peak shaving. One of the buildings at Universiti Tunku Abdul Rahman (UTAR), Malaysia, is chosen for this study. A three-phase energy storage system rated at 15 kVA is developed and connected to the low-voltage electrical network in the building. An adaptive control algorithm is developed and implemented to optimize the peak shaving. Findings - The sizing analysis shows that the customer under the C2 tariff rate yields the highest saving, followed by E2, C1 and E1. The experimental results presented indicate that the proposed adaptive control algorithm has effectively optimized the peak demand to be shaved. Research limitations/implications - This study demonstrates the potential of energy storage in reducing the peak demand and cost of electricity. One of the main challenges of real-time peak shaving is to determine an appropriate threshold level such that the energy stored in the energy storage system is sufficient during the peak shaving process. Originality/value - The originality of the paper is the optimal sizing method of the energy storage system based on the historical load profile and adaptive control algorithm to optimize the peak demand deduction.