Infiltrating T lymphocytes are frequently found in malignant tumors and are suggestive of a host cancer immune response. Multiple independent studies have documented that the presence and quantity of tumor-infiltrating lymphocytes (TILs) are strongly correlated with increased survival. However, because of methodological factors, the exact effect of TILs on prognosis has remained enigmatic, and inclusion of TILs in standard prognostic panels has been limited. For example, some reports enumerate all CD3(+) cells, some count only cytotoxic CD8(+) T cells, and the criteria used to score tumors as TIL-positive or TIL-negative are inconsistent among studies. To address this limitation, we introduce a robust digital DNA-based assay, termed QuanTILfy, to count TILs and assess T cell clonality in tissue samples, including tumors. We demonstrate the clonal specificity of this approach by the diagnosis of T cell acute lymphoblastic leukemia and the accurate, sensitive, and highly reproducible measurement of TILs in primary and metastatic ovarian cancer. Our experiments demonstrate an association between higher TIL counts and improved survival among women with ovarian cancer, and are consistent with previous observations that the immune response against ovarian cancer is a meaningful and independent prognostic factor. Surprisingly, the TIL repertoire is diverse for all tumors in the study with no notable oligoclonal expansions. Furthermore, because variability in the measurement and characterization of TILs has limited their clinical utility as biomarkers, these results highlight the significant translational potential of a robust, standardizable DNA-based assay to assess TILs in a variety of cancer types.