This paper presents an ensemble learning particle swarm optimization (ELPSO) algorithm for real-time indoor localization based on ultra-wideband (UWB). Indoor localization problem can be formulated as an optimization problem to predict the target. The proposed algorithm expands the original PSO into ELPSO under superbest guide, which is a parameter employed to identify the top gbest by learning from three individual algorithms and updated asynchronously. The performance of the proposed ELPSO is evaluated by using the CEC2005 benchmark and compared with each individual algorithm and other state-of-the-art optimization algorithms. The feasibility of the proposed ELPSO is demonstrated in both 2D and 3D UWB indoor localization system generating promising results.