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). 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).