How to download OptiFine from the official site
Find your exact Minecraft: Java Edition version on optifine.net. Click (Mirror) beside the matching OptiFine build, then click Download on the file page to save the JAR.
Choose the standalone installer, a Forge profile or a managed modpack. Match the JAR to the Minecraft Java version that installation runs.
Run the exact Minecraft Java version once before using the standalone installer. A Forge installation uses the intact JAR in its own mods folder. The developer’s downloads page shows which game version and Forge build go with each file.
Set up the standalone installation and check the profile you launch.
Find the Mac game folder and learn which launch route fits your Java installation.
Add the file to the correct modpack without changing the original profile.
Read the catalog row and check the filename before opening it.
Start with the full error message before replacing a file or Java runtime.
Find your exact Minecraft: Java Edition version on optifine.net. Click (Mirror) beside the matching OptiFine build, then click Download on the file page to save the JAR.
Put the official OptiFine JAR in the mods folder of your compatible Minecraft Java Forge instance. Open that folder from the three-dot menu in CurseForge or Modrinth App.
Follow the same-site Mirror route, check the exact JAR name, and know when to stop before opening a download.
Prepare the exact Minecraft version and a supported desktop Java runtime, install J9 into the launcher data root, then select its OptiFine installation.
Run your exact Minecraft: Java Edition version once, open the matching OptiFine JAR and click Install. Then select OptiFine in Minecraft Launcher. On compatible Forge, put the intact JAR in that installation's mods folder and launch Forge.