We describe two algorithms to diagnose basal cell carcinomas (BCCs) and melanomas (MMs) using in vivo reflectance confocal microscopy (RCM). A total of 710 consecutive cutaneous lesions excised to exclude malignancy (216 MMs, 266 nevi, 119 BCCs, 67 pigmented facial macules, and 42 other skin tumors) were imaged by RCM. RCM features were correlated with pathology diagnosis to develop diagnostic algorithms. The diagnostic accuracy of the BCC algorithm defined on multivariate analysis of the training set (50%) and tested on the remaining cases was 100% sensitivity, 88.5% specificity. Positive features were polarized elongated features, telangiectasia and convoluted vessels, basaloid nodules, and epidermal shadowing corresponding to horizontal clefting. Negative features were non-visible papillae, disarrangement of the epidermal layer, and cerebriform nests. Multivariate discriminant analysis on the training set (excluding the BCCs) identified seven independently significant features for MM diagnosis. The diagnostic accuracy of the MM algorithm on the test set was 87.6% sensitivity, 70.8% specificity. The four invasive MMs that were misdiagnosed by RCM were all of nevoid subtype. RCM is a highly accurate non-invasive technique for BCC diagnosis. Good diagnostic accuracy was achieved also for MM diagnosis, although rare variants of melanocytic tumors may limit the strict application of the algorithm.