One of the significant challenges toward utilizing hybrid energy storage systems (HESSs) in microgrids (MGs) is the accurate sizing of the storage devices. This article developed an effective method that evaluates battery lifetime's impact on the optimal size of a HESS considering the total cost function minimization. Therefore, high-frequency powers are provided by supercapacitor (SC), and the battery provides low-frequency power. Besides, implementing discrete Fourier transform (DFT) and the particle swarm optimization (PSO) algorithm is also proposed to achieve optimal HESS sizing in MG. The difference between power generation and load consumption is transferred to the frequency domain, and after determining the cut-off frequency, the optimized cost function is obtained. The suggested sizing strategy has been validated with actual data of solar radiation, wind speed, and load profile on an MG. Compared to just utilizing battery storage, the system's total cost is decreased by employing the proposed HESS configuration, and its dynamic performance is improved by allocating high-frequency power to the SCs. Considering the battery lifetime, it would be observed that implementing HESS List of Symbols and Abbreviations: I ph , PV current source; R s , series cells resistance; R p , parallel cells resistance; T a , ambient temperature; NOCT, cell temperature under operating conditions; T aNOCT , ambient temperature in which NOCT is defined; G, sun's radiation; G NOCT , amount of solar radiation; I scref , short circuit current at reference temperature; G ref , light reference radiation; α isc , short circuit current coefficient; T ref , solar cell reference temperature; V ocref , open-circuit voltage at standard conditions; α voc , voltage temperature coefficient; q, electron columbic charge; n, diode factor; k, Boltzmann constant; N s , number of attached cells in series; R 0 , electrode resistance; R 1 , loss of power; V T , battery terminal voltage; V oc , unloaded voltage condition of the battery; Ah, nominal capacity of the battery; I batt , battery current; SOC, battery charge state; SOC init , initial battery charge; K e , anti-propulsion voltage on SOC; I 2 , current flow through R 1 ; ΔV, SC voltage changes; ΔI, current flow changes; I c , SC charging current; t c , SC charging time; C ucapR , SC's nominal capacity; P w , wind turbine output power; P r , nominal turbine power; V r , nominal velocity; V co , upper turbine speed limit; V ci , lower turbine speed limit; A w , total surface area; η g , electrical efficiency; E Disch , amount of discharged energy; V Bat , battery voltage; S life , system lifetime; K life , lifetime coefficient; C rep , replacement factor; v i , velocity of a particle ith; c 1 , c 2 , learning factors; r 1 , random number; P best , best solution; G best , best global solution; x i , position of a particle; N, number of samples; A(k), signal amplitude; f(k), frequency; η d , discharging efficiency; η c , charging efficiency; CA Bat , Battery cost per unit; CA SC , SC cost per unit;...