There may be scenarios in which you would want to access your game files directly, such as to back up or transfer a world save, or to modify files. The following lists how to access your game files directly:
Minecraft: Java Edition
The file to run the launcher is wherever you put it. This may or may not default to your desktop or downloads folder. The remaining launcher files can be found by starting the launcher, logging in, going to "Launch options", choosing a launch configuration from the list ("Latest release" is the default) and clicking the little green arrow to the right of the "Game directory" option.
Press Win+R, then type %appdata%\.minecraft, then press Ok.
In the Finder, from the Go menu, select 'Go to Folder', then type: ~/Library/Application Support/minecraft, and click Go.
~ is your home directory, usually /home/YOURNAME, so ~/.minecraft would be /home/YOURNAME/.minecraft/.
Minecraft on other platforms:
Android & Amazon Fire OS
Minecraft for Windows 10 & Windows Phone
C:\Users\(your pc username)\AppData\Local\Packages\Microsoft.MinecraftUWP_8wekyb3d8bbwe\LocalState\games\com.mojang\
Minecraft for Xbox one files are stored locally on the console. If you sign in with an Xbox Live account, your worlds will also be backed up to Xbox One cloud game saves.