Pack.mcmeta Tutorial
by WafflesAreBetter
What is pack.mcmeta?
Every Minecraft data pack and resource pack must have a pack.mcmeta file. If the pack.mcmeta file is not set up correctly, you won’t be able to load the pack.
The pack.mcmeta file is what the game uses to determine whether a folder is a pack or not – if your data pack or resource pack doesn’t have a pack.mcmeta file, the game doesn’t know it’s a data pack/resource pack.
The pack.mcmeta file also tells your game important information about your data pack or resource pack, such as whether it’s compatible with the game version or what the pack is used for. If you wish to add a new language to the game using a resource pack, you’ll need to specify that in the pack.mcmeta file as well.
If you want to watch a video instead:
File placement and names
The pack.mcmeta file needs to be named pack and it must have the .mcmeta file extension, it can’t be a .txt file or anything else. The pack.mcmeta file should be placed directly within the main folder of your data or resource pack, alongside the data or assets folder and the pack.png file (if you have one of those, which is optional). The screenshot here taken in Visual Studio Code, and shows where pack.mcmeta should be placed.
(Note that if you’re making a resource pack instead of a data pack, the folder that’s named data in the screenshot will be named assets for you.)
Here’s a pastebin link for the contents of an example pack.mcmeta file that you can use, the code inside and what it means is explained below. Here’s a download link for an example data pack that contains a pack.mcmeta file, so you can see where it should be placed (you’ll need to unzip it). Note that the pack.mcmeta file in the download is for the version 1.19.4, so check the stuff below to know what to change and how to customize it :)

Basic contents
Because pack.mcmeta is a JSON file, it starts and ends with curly brackets ({}). A basic pack.mcmeta file only has one object in it, pack, which contains pack_format and description.
The value of pack_format, which must be an integer (a whole number, like 3 or 6), is what tells Minecraft which game versions the data or resource pack is designed for. For 1.19.4 data packs, the pack format is 12 (see below for which pack format numbers correspond to other game versions). The pack format is not what actually makes your pack compatible with a given version, it just tells the user whether the pack was designed for the version they’re currently using. For example, if all of the code in your data pack is written for version 1.19.4 but your pack format in pack.mcmeta is set to 7, when someone tries to enable it in 1.19.4, it will be listed as Incompatible and be highlighted in red. If the user then enables it anyway and bypasses the warning, since the pack was actually written for 1.19.4, it will work as intended. However, if someone tries to enable it in 1.17 (the version for pack format 7), Minecraft will tell them that the pack was made for that version, but the data pack won’t work when enabled because it was made for a different version of the game.