In this paper, the analytical solution to the planar magnetic field of a linear permanent magnet Halbach array is researched on. First, the magnetic field of a current surface is derived from the magnetic field produced by the molecular current of the permanent magnet. The magnetic fields of pieces of permanent magnet with vertical and diagonal magnetization direction are both solved by combining the magnetic field of current surfaces with different directions. Then the planar magnetic field of the entire linear permanent magnet Halbach array is obtained by calculating the vector addition of the magnetic field of all the permanent magnet cubes using Denavit-Hartenberg (D-H) transform technique, which yields the closed-form analytical expressions. The analytical algorithm proposed in this paper can be utilized to design and optimize the Halbach array, which in result can greatly simplify the calculation and expedite the progress. The effectiveness of the proposed method is evaluated by the finite element analysis software Maxwell.