Cytochrome P450 monooxygenase that catalyzes regio- and stereospecific hydroxylation of cholesterol and its derivatives. Hydroxylates (with R stereochemistry) the terminal methyl group of cholesterol side-chain in a three step reaction to yield at first a C26 alcohol, then a C26 aldehyde and finally a C26 acid (PubMed:12077124, PubMed:21411718, PubMed:28190002, PubMed:9660774). Regulates cholesterol homeostasis by catalyzing the conversion of excess cholesterol to bile acids via both the 'neutral' (classic) and the 'acid' (alternative) pathways (PubMed:11412116, PubMed:1708392, PubMed:2019602, PubMed:7915755, PubMed:9186905, PubMed:9660774, PubMed:9790667). May also regulate cholesterol homeostasis via generation of active oxysterols, which act as ligands for NR1H2 and NR1H3 nuclear receptors, modulating the transcription of genes involved in lipid metabolism (PubMed:12077124, PubMed:9660774). Catalyzes the conversion of 7-ketocholesterol (7-oxocholesterol) into 7-keto,27- hydroxycholesterol, a precursor of 7-keto,27-hydroxycholesterol, an active oxysterol that activates smoothened (SMO) and the smoothened signaling pathway (By similarity). Plays a role in cholestanol metabolism in the cerebellum. Similarly to cholesterol, hydroxylates cholestanol and may facilitate sterol diffusion through the blood-brain barrier to the systemic circulation for further degradation (PubMed:28190002). Also hydroxylates retinal 7-ketocholesterol, a noxious oxysterol with pro-inflammatory and pro-apoptotic effects, and may play a role in its elimination from the retinal pigment epithelium (PubMed:21411718). May play a redundant role in vitamin D biosynthesis. Catalyzes 25-hydroxylation of vitamin D3 that is required for its conversion to a functionally active form (PubMed:15465040). {ECO:0000250|UniProtKB:Q9DBG1, ECO:0000269|PubMed:11412116, ECO:0000269|PubMed:12077124, ECO:0000269|PubMed:15465040, ECO:0000269|PubMed:1708392, ECO:0000269|PubMed:2019602, ECO:0000269|PubMed:21411718, ECO:0000269|PubMed:28190002, ECO:0000269|PubMed:7915755, ECO:0000269|PubMed:9186905, ECO:0000269|PubMed:9660774, ECO:0000269|PubMed:9790667}. This is the function of CYP27A1 (cytochrome P450 family 27 subfamily A member 1, Ensembl gene identifier ENSG00000135929).