Melanoma is a highly malignant skin tumor with poor prognosis. Circadian rhythm is closely related to melanoma pathogenesis. This study aimed to identify key circadian rhythm genes (CRGs) in melanoma and explore their potential as diagnostic and prognostic biomarkers. Microarray data of melanoma tissues and normal skins were obtained. Differentially expressed genes were identified and weighted gene co-expression network analysis (WGCNA) was performed to screen hub genes associated with melanoma. By overlapping hub genes with known CRGs, 125 melanoma-related CRGs were identified. Functional enrichment analysis revealed these CRGs were mainly involved in circadian rhythm and other cancer-related pathways. Three machine learning algorithms including LASSO regression, support vector machine-recursive feature elimination (SVM-RFE), and random forest were utilized to select key CRGs. Six CRGs (ABCC2, CA14, EGR3, FBXW7, LDHB, and PSEN2) were identified as key CRGs for melanoma diagnosis and prognosis. Diagnostic values of key CRGs were evaluated by ROC analysis in training and validation sets. Prognostic values of key CRGs were assessed by survival analysis and a multivariate Cox regression prognostic model was constructed. The prognostic model could effectively stratify melanoma patients into high- and low-risk groups with significantly different survival. A nomogram integrating clinical variables and risk score was built to predict 3-, 5- and 10-year overall survival of melanoma patients. In summary, six CRGs were identified as key genes associated with melanoma pathogenesis and may serve as promising diagnostic and prognostic biomarkers. The prognostic model and nomogram could facilitate personalized prognosis evaluation of melanoma patients.