An all-optical approach to implementing short-time Fourier transform (STFT) of a high-speed and broadband electrical signal is proposed and demonstrated for the first time to our knowledge. The STFT is implemented based on a temporal pulse shaping system incorporating an array of cascaded linearly chirped fiber Bragg gratings (LCFBGs). An electrical signal to be analyzed is applied to a Mach-Zehnder modulator (MZM) to modulate the optical spectrum of a time-stretched optical pulse from a mode-locked laser (MLL). Each individual LCFBG in the LCFBG array functions as a bandpass filter to filter a specific range of the spectrum, which is equivalent to applying a window function to the corresponding section of the temporal signal, and at the same time, as a dispersive element to implement real-time Fourier transform. A theoretical analysis is performed which is verified by a numerical simulation and a proof-of-concept experiment. The key feature of this technique is that STFT can be implemented in real time which can find applications in analyzing an electrical signal with a bandwidth up to several hundreds of gigahertz.