Accurate location information has significant commercial and economic value as they are widely used in intelligent manufacturing, material localization and smart homes. Magnetic sequence-based approaches show great promise mainly due to their pervasiveness and stability. However, existing geomagnetic indoor localization methods are facing the problems of location ambiguity and feature extraction deficiency, which will lead to large localization errors. To address these issues, we propose a coarse-to-fine geomagnetic indoor localization method based on deep learning. First, a multidimensional geomagnetic feature extraction method is presented which can extract magnetic features from spatial and temporal aspects. Then, a hierarchical deep neural network model is devised to extract more accurate geomagnetic information and corresponding location clues for more accurate localization. Finally, localization is achieved through a particle filter combined with IMU localization. To evaluate the performance of the proposed methods, we carried out several experiments at three trial paths with two heterogeneous devices, Vivo X30 and Huawei Mate30. Experimental results demonstrate that the proposed algorithm can achieve more accurate localization performance than the state-of-the-art methods. Meanwhile, the proposed algorithm has low cost and good pervasiveness for different devices.