Skip to main content
← All Guides
Datapacks

How to make a datapack in Minecraft

A datapack is just two things done right: a pack.mcmeta file and a .mcfunction in the correct folder. Get the nesting exact, run /reload and call it with /function welcome:hello. No mods, no plugins.

world/datapacks/welcome, server console
welcome/
pack.mcmeta
data/
welcome/
function/
hello.mcfunction
# pack.mcmeta
{ "pack": { "pack_format": 48 } }
# hello.mcfunction
say Welcome to the server!
effect give @a regeneration 10 1
> /reload
[Server] Reloading! Loaded 1 datapack: welcome
> /function welcome:hello
[Server] Welcome to the server!
Executed 2 commands from welcome:hello
datapack loaded
The folder layout that actually loads

The single most common failure is the path. Your function must live at welcome/data/welcome/function/hello.mcfunction. On 1.21+ the folder is function (singular); on 1.20.x and earlier it was functions. Pick the one that matches your pack_format.

To run code on load, add data/minecraft/tags/function/load.json with { "values": ["welcome:hello"] }. Use tags/function/tick.json for code that runs every tick. Validate the JSON before /reload or the whole pack silently fails.

Quick answers

+What pack_format should I use?
It matches the game version: 48 for 1.21, 41 for 1.20.5 and 1.20.6, 26 for 1.20.3 and 1.20.4, 18 for 1.20.2. Use the wrong number and the pack shows as incompatible. Set it in pack.mcmeta and update it when you upgrade.
+Why does /reload say my datapack is invalid?
Almost always a path or JSON typo. Check the nesting is data/welcome/function/, that pack.mcmeta is valid JSON, and that the folder is function (not functions) on 1.21+.
+Do commands inside .mcfunction need a slash?
No. Inside a .mcfunction file you write commands without the leading /. You only use the slash when typing in chat, like /function welcome:hello.
+What is the namespace in /function welcome:hello?
welcome is the namespace, the folder directly under data/. hello is the function name from hello.mcfunction. The format is always namespace:path/to/function.
+How do I make it run automatically?
Add a tag: data/minecraft/tags/function/load.json listing your function. minecraft:load runs on every /reload, minecraft:tick runs every game tick.
+Where do datapacks go on a server?
In your world folder under datapacks/ (for example world/datapacks/welcome). Drop the folder in, run /reload, and confirm it loaded in the console.
+Why does it work as a folder but break as a .zip?
A zipped pack must have pack.mcmeta and the data folder at the root of the zip, not inside an extra welcome/ folder. If you zip the parent folder you get welcome/pack.mcmeta inside the archive and the game ignores it. Re-zip from inside the pack folder so pack.mcmeta sits at the top level.
+My pack loads but the function does nothing. Why?
Run /function welcome:hello by hand first. If that fires the commands, your load.json tag is wrong. If it errors with Unknown function, the file name or namespace is off. Check that hello.mcfunction is plain text with no .txt extension hidden by your OS, and that there is no blank namespace folder.
+Can one datapack hold more than one function?
Yes. Add as many .mcfunction files as you want under data/welcome/function/, each callable as welcome:name. Subfolders work too: data/welcome/function/setup/spawn.mcfunction is called with /function welcome:setup/spawn.
+Does pack_format change for resource packs?
Yes, the numbers differ between datapacks and resource packs even on the same version. For 1.21 a datapack uses pack_format 48 while a resource pack uses 34. Do not copy a resource pack number into a datapack pack.mcmeta.
+How do I run a function on a delay or repeat?
Use schedule inside a function: schedule function welcome:hello 100t queues it 100 ticks (5 seconds) later. For a loop, put schedule function welcome:loop 20t at the end of the loop function so it re-queues itself every second.

Mistakes that silently break a pack

Most failed packs are not bugs, they are typos in a path or a stray character. Check these before you blame the code:

  • Editor saved the file as hello.mcfunction.txt. Turn on file extensions in your OS and remove the extra .txt. The game only reads .mcfunction.
  • Comma after the last value in pack.mcmeta. JSON does not allow a trailing comma, and one extra comma marks the whole pack incompatible.
  • Wrong folder name on 1.21+. It is function and tags/function, both singular. The plural functions only worked through 1.20.x.
  • Spaces or capitals in the namespace. Use lowercase letters, numbers, and underscores only, so welcome not Welcome Pack.

After any edit, /reload reapplies the pack without leaving the world. Watch the chat line: Reloading! followed by no error means it parsed. If a function still does nothing, run it directly with /function welcome:hello to separate a broken tag from a broken command. To confirm a pack is active at any time, run /datapack list and look for it under the enabled list.

Hosting
Skip the setup
Get a managed server with one click instead of configuring it all yourself.
Database
Browse every effect & item
Look up IDs, effects and item names to drop straight into your .mcfunction commands.