Prediabetes, a subclinical state of high glucose, carries a risk of transition to diabetes. One cause of prediabetes is insulin resistance, which impairs the ability of insulin to control blood glucose. However, many individuals with high insulin resistance retain normal glucose due to compensation by enhanced insulin secretion by beta cells. Individuals seem to differ in their maximum compensation level, termed beta cell carrying capacity, such that low carrying capacity is associated with a higher risk of prediabetes and diabetes. Carrying capacity has not been quantified using a mathematical model and cannot be estimated directly from measured glucose and insulin levels in patients, unlike insulin resistance and beta cell function which can be estimated using HOMA-IR and HOMA-B formula.Here we present a mathematical model of beta cell compensation and carrying capacity, and develop a new formula called HOMA-C to estimate it from glucose and insulin measurements. HOMA-C estimates the maximal potential beta cell function of an individual, rather than the current beta cell function. We test this approach using longitudinal cohorts of prediabetic people, finding 10-fold variation in carrying capacity. Low carrying capacity is associated with higher risk of transitioning to diabetes. We estimate the timescales of beta cell compensation and insulin resistance using large datasets, showing that, unlike previous mathematical models, the new model can explain the slow rise in glucose over decades. Our mathematical understanding of beta cell carrying capacity may help to assess the risk of prediabetes in each individual.