Buried pipelines must exhibit the appropriate seismic performance to be applied practically and securely. One major pipeline failure mode is buckling caused by seismic ground motion. Buckling typically occurs in straight pipeline sections because seismic axial loads mainly accumulate along straight lines. The design method for defining a maximum straight pipe length to decrease seismic axial loads is known to be effective in preventing buckling. Based on this previous knowledge, this study develops a theoretical formula for estimating the maximum straight length to prevent buckling. The proposed formula is derived using an analytical pipeline model with soil springs under seismic ground motion. Using this analytical model, the seismic loads which are applied to the straight pipe and the pipe connected to the straight pipe are calculated respectively. Then, the formula for the maximum straight length is derived by calculating the straight pipe length where the axial stress in the straight pipe is equal to the yield stress. The proposed formula is validated through finite element analysis. The maximum straight lengths obtained by the theoretical formula are in good agreement with FEM or shorter, thus providing a margin of safety. This work can be useful in designing buried pipelines to prevent buckling failures, thus enabling safer and more viable pipelines.