Cone penetration test (CPT) data contains detailed stratigraphic information that is useful in a wide variety of applications. Separating a CPT profile into discrete layers is an important part of many analyses such as critical layer selection in liquefaction triggering analysis, effective stress seismic ground response analysis, analysis of pile shaft and tip resistance, and soil-pile interaction analysis. The discretization of the profile into layers is often done manually, relying on the judgment of the analyst. This manual approach is cumbersome for datasets that include large numbers of CPT profiles (such as the Next Generation Liquefaction [NGL] database and the New Zealand Geotechnical Database) and it may not be consistent or repeatable because different analysts may discretize a given CPT log in different ways. To overcome these difficulties, we present an approach to automatically divide a CPT profile into discrete layers. Automated layer detection is performed using an unsupervised machine learning technique called agglomerative clustering in combination with two cost functions to identify an optimal number of layers. The algorithm is illustrated using CPT profiles from the NGL database, where the approach is being used in the development of liquefaction triggering and manifestation models. Although the algorithm shows promise for replicating our judgment regarding layering, we recommend visual review of the layering produced by the algorithm to check for reasonableness given the site geology and intended use of the CPT data.