The vigorous development of electric vehicles (EVs) is an important means of reducing carbon emissions and mitigating environmental problems such as the greenhouse effect. Battery swapping stations (BSSs) can both provide battery swapping services for large-scale EVs and charge batteries centrally. As the supply of fully charged batteries in the BSS shrinks, it becomes necessary to schedule the charging of the depleted batteries rapidly that users have swapped for fully-charged ones. The charging schedule for depleted batteries must be made without knowledge of future battery arrivals. In this context, this paper develops a mathematical model for online charging scheduling of BSSs, formulates the charging strategy as a two-dimensional rectangle packing problem, and quickly calculates the scheduling arrangement of batteries by partitioning the remaining available capacity of a BSS. Since there are limited battery types within the BSS which can provide battery replacement services, this paper supplements the proposed model with known battery types, which improves the utilization of the available capacity of BSSs. Finally, numerical results verify the effectiveness of the proposed model. <italic xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink">Note to Practitioners</i> —Electric vehicles (EVs) are becoming an alternative way to reduce carbon emissions in transportation systems. Herein, the optimal battery charging problem is the core problem when it comes to dispatching a huge number of EVs. Up to now, battery-swapping is widely used for EVs due to its simple, convenient way. Furthermore, a business model for the battery swapping stations (BSSs) is brought up, where EV users send their depleted batteries to the BSS and the BSS provides the users with a fully charged replacement battery from its warehouse, which only takes a few minutes. Since the maximum charging power of the BSS is limited by the capacity of the transformer connecting the BSS to the power grid, the BSS will adopt an optimal charging schedule that maximizes the charging benefit for large quantities of depleted batteries in the warehouse. However, the challenge is that the charging schedule for depleted batteries must be made without knowledge of future battery arrivals because the EV behaviors are difficult to predict. To address this problem, this paper developed an online charging scheduling algorithm, which formulates the charging strategy as a two-dimensional rectangle packing problem. The proposed method can provide battery replacement services in real-time and solve quickly without any information about incoming depleted EV batteries. The proposed model and method have been tested on the system with different numbers of batteries to show the effectiveness. Besides, the online two-dimensional rectangle packing problem can provide an online decision for BSSs.