Klebsiella pneumoniae has emerged as a global health threat due to its role in the spread of antimicrobial resistance and because it is a frequent cause of hospital-acquired infections and neonatal sepsis. Capsular and lipopolysaccharide (LPS) O-antigen polysaccharide surface antigens are major immunogens that are useful for strain classification and are candidates for vaccine development. We have developed real-time PCR reagents for molecular serotyping, subtyping, and quantitation of the most prevalent LPS O-antigen types (i.e., O1, O2, O3, and O5) of Klebsiella pneumoniae. We describe two applications for this O-typing assay: for screening culture isolates and for direct typing of Klebsiella pneumoniae present in stool samples. We find 100% concordance between the results of the O-typing assay and whole-genome sequencing of 81 culture isolates, and >90% agreement in O-typing performed directly on specimens of human stool, with disagreement arising primarily from a lack of sensitivity of the culture-based comparator method. Additionally, we find evidence for mixed O-type populations at varying levels of abundance in direct tests of stool from a hospitalized patient population. Taken together, these results demonstrate that this novel O-typing assay can be a useful tool for K. pneumoniae epidemiologic and vaccine studies.IMPORTANCEKlebsiella pneumoniae is an important opportunistic pathogen. The gastrointestinal (GI) tract is the primary reservoir of K. pneumoniae in humans, and GI carriage is believed to be a prerequisite for invasive infection. Knowledge about the dynamics and duration of GI carriage has been hampered by the lack of tools suitable for detection and strain discrimination. Real-time PCR is particularly suited to the higher-throughput workflows used in population-based studies, which are needed to improve our understanding of carriage dynamics and the factors influencing K. pneumoniae colonization.