Function Command Generator — /function with Macro Arguments (Java Edition)
Run these from an operator’s chat, a command block, or a function file. Execute is simplified here — chain the rows in the order you want them to run.
How to Use the Function Command Generator
- Open the Function tab.
- Enter the function’s namespaced ID, e.g.
mynamespace:my_function. - Check Use macro arguments if the function is written with
$(...)macro placeholders that need values passed in. - If checked, enter the arguments as a JSON object, e.g.
{"arg1":"value"}– keys must match the macro names used inside the function file. - Copy the generated
/functioncommand into a command block, another function file, or an operator’s chat.
Command Syntax Reference
/function <function> /function <function> <arguments>
/function <function> runs every command in that data-pack function file in order, as if you’d typed each line yourself (subject to the usual command limits per tick). The second form passes a JSON object of macro arguments – this only does something if the function file itself is written as a macro function, using $(argName) placeholders inside its command lines (a Minecraft feature that substitutes each placeholder with the matching value from the JSON object at call time, letting one function file behave differently per call instead of being hardcoded).
Frequently Asked Questions
What is a macro function, and how is it different from a regular one?
A regular function file just runs the same fixed commands every time it’s called. A macro function has one or more $(argName) placeholders written directly into its command lines – when called with a JSON arguments object, each placeholder gets substituted with the matching key’s value before that line runs, so the same function file can behave differently depending on what you pass in, without needing a separate copy for each variant.
What happens if my JSON arguments object is missing a key the function expects?
The macro substitution for that missing key fails, which causes an error on the command line using that placeholder specifically – commands before the failing line still ran normally, but the line needing the missing argument (and typically the rest of that function’s remaining commands, depending on how it’s structured) won’t complete as expected. Always match your JSON keys exactly to the macro names the function file actually references.
Can a function called with /function call other functions itself?
Yes – nesting is completely normal, and a function file often ends with one or more /function calls to other functions to break logic into smaller, reusable pieces. Minecraft does cap how deep function calls can nest and how many total commands run per tick, but ordinary nesting for organization purposes is standard practice, not something to avoid.
Do macro arguments need to be strings, or can they be numbers and other JSON types?
Macro arguments can be any JSON value type valid for the context they’re substituted into – strings, numbers, and booleans are common, and the substitution is essentially textual, so the resulting command line just needs to still be valid Minecraft syntax after the placeholder is replaced with whatever value you supplied.
Does /function run the whole file instantly, or one command per tick?
All commands in the function run within the same game tick as the call, one after another in order (subject to Minecraft’s overall per-tick command execution limit) – it is not spread out one line per tick. For anything that needs an actual delay between steps, pair it with /schedule to call a follow-up function later instead of relying on /function itself to pause.
Related Tools
- Schedule Command Generator – delay a
/functioncall instead of running it immediately. - Execute Command Generator – run a function as a specific entity or at a specific position with
execute as/at/run function. - Scoreboard Command Generator – track state across repeated function calls.