The literature on class size yields a number of findings. First, class size effects are difficult to find except when using data where class size variations are truly exogenous. Second, Catholic schools have large classes and better performance. Third, to the extent that class size matters, it is more important for disadvantaged children. Special education classes are smaller than advanced placement classes. Fourth, when many children have joined a class recently, the joiners and their classmates do worse. The theory presented below reconciles all of these facts by recognizing that classroom teaching is a public good where congestion effects are potentially important. Because the optimal class size is larger for behaved-students, the observed relation of educational output to class size is small or even positive. However, increasing class size to ranges away from equilibrium levels will adversely affect educational output. The theory argues for a particular non-linear relation of educational output to class size and is consistent with observed variations in class size by grade level, student and teacher characteristics. Class sizes are more significant in small classes than large ones. There is a special function that maps the substitution of discipline for class size, which may explain why Catholic schools, with large classes, out-perform public schools. The same technology also implies that class size effects are larger for problem children than for well-behaved children. Private schools, which charge a positive price and compete with free public schools, attract better students. This selection may help explain why Catholic schools out-perform public schools even though expulsion rates are lower in Catholic schools than in public ones. Teachers may prefer smaller class size than students or parents either because wages do not reflect working conditions fully or because teachers as a group can raise the demand for their services by lowering class size. The theory provides a measurable and operational way to define school quality that can be tested empirically. Finally, because public schools that operate in a centralized environment do not capture the returns to their successes, public school incentives differ from those of private schools.