Input

Wiki

Convert a mathematical expression into a Minecraft number provider JSON. Write a formula using variables, arithmetic operators and built-in functions, choose the provider type (Integer or Float), and the generator produces the corresponding JSON ready to paste into a datapack or command block.

Desmos Import
Import is experimental and may not work with 100% accuracy.
Help & Hints

This generator translates a mathematical expression into a Minecraft number provider JSON structure. Use standard operators (+, -, *, /, ^), parentheses, numbers, variables and function calls. Each variable must have a value source (score, storage or environment attribute). The provider type (Integer or Float) determines which functions are native; functions of the opposite type are automatically wrapped in from_int / from_float for conversion. The result can be copied in JSON or compact SNBT format using the format switcher above the output.

Implicit multiplication is supported: you can write 5x instead of 5*x, 2(x+1) instead of 2*(x+1), or x(9y-1) instead of x*(9*y-1). Consecutive letters are treated as separate variables multiplied together: abc means a*b*c. To group letters into a single multi-letter variable name, wrap them in apostrophes: 'ab'c means ab*c. Function names (like abs, cos) are recognized automatically and not split.

Pre-calculation with !expr!: wrap an arithmetic expression in exclamation marks to evaluate it at generation time and insert the result as a plain number. For example, !20*60*5! becomes 6000 in the output (not const(20)*const(60)*const(5)). This is useful for unit conversions like ticks → seconds: !20*60*5! for 5 minutes in ticks. Inside !! you can use numbers, operators (+ - * / ^), parentheses, and built-in constants (pi, e, tau, phi, sqrt2, sqrt3). Variables and functions are not allowed inside !!.

Constant source also supports formulas: when a variable's source is set to constant, you can enter either a plain number (e.g. 3.14) or a formula (e.g. 20*60*5) without !!. The evaluated result is shown next to the input with = for immediate feedback.

Reverse conversion: you can edit the JSON in the Result panel directly, or paste an existing number provider JSON there — the formula is automatically updated. You can also drag & drop a .json file anywhere on the page to import it. Errors are shown as a toast notification in the top-right corner and do not clear your JSON.

Common operations (both Integer and Float)
+ — addition (→ minecraft:add, inputs)
- — subtraction (→ minecraft:sub, left/right)
* — multiplication (→ minecraft:mul, inputs)
/ — division (→ minecraft:div, left/right)
^ — power (→ minecraft:pow, base/exponent)
abs(x) — absolute value (→ minecraft:abs, input)
negate(x) — negation (→ minecraft:negate, input)
div(a,b) — division (→ minecraft:div, left/right)
mod(a,b) — modulo (→ minecraft:mod, left/right)
sub(a,b) — subtraction (→ minecraft:sub, left/right)
add(a,b,...) — sum (→ minecraft:add, inputs)
avg(a,b,...) — average (→ minecraft:average, operands)
max(a,b,...) — maximum (→ minecraft:maximum, operands)
min(a,b,...) — minimum (→ minecraft:minimum, operands)
mul(a,b,...) — product (→ minecraft:mul, inputs)
pow(base,exp) — power (→ minecraft:pow, base/exponent)
uniform(min,max) — uniform distribution (→ minecraft:uniform, min/max)
const(n) — constant (→ minecraft:constant, value)
weighted_list[(w,v),(w,v),...] — weighted distribution (→ minecraft:weighted_list, distribution)
   w = integer weight, v = number provider / value; alias: wl[...]
Parentheses (), numbers, variables. Spaces are ignored.
Integer-native operations (auto-wrapped in from_int when used in Float)
from_float(x) — convert float to int (→ minecraft:from_float, input)
floor_div(a,b) — floor division (→ minecraft:floor_div, left/right)
floor_mod(a,b) — floor modulo (→ minecraft:floor_mod, left/right)
binomial(n,p) — binomial distribution (→ minecraft:binomial, n/p)
Float-native operations (auto-wrapped in from_float when used in Integer)
cos(x) — cosine (→ minecraft:cos, input)
ceil(x) — ceiling (→ minecraft:ceil, input)
floor(x) — floor (→ minecraft:floor, input)
from_int(x) — convert int to float (→ minecraft:from_int, input)
round(x) — round (→ minecraft:round, input)
sin(x) — sine (→ minecraft:sin, input)
sqrt(x) — square root (→ minecraft:sqrt, input)
truncate(x) or trunc(x) — truncate fraction (→ minecraft:truncate, input)
length(a,b,...) — vector length / hypotenuse, sqrt(a²+b²+...) (→ minecraft:length, inputs)
Derived trigonometric & hyperbolic (float-only macros)
These functions are not native Minecraft number providers but are expanded into combinations of sin, cos, pow, and negate.
They are float-only and auto-wrapped in from_float() when used in an Integer provider.

Trigonometric (via sin/cos):
tan(x) — tangent → sin(x)/cos(x)
cot(x) — cotangent → cos(x)/sin(x)
sec(x) — secant → 1/cos(x)
csc(x) — cosecant → 1/sin(x)

Hyperbolic (via pow with e ≈ 2.718281828):
sinh(x) — hyperbolic sine → (e^x − e^(negate(x)))/2
cosh(x) — hyperbolic cosine → (e^x + e^(negate(x)))/2
tanh(x) — hyperbolic tangent → (e^x − e^(negate(x)))/(e^x + e^(negate(x)))

Examples:
tan(x)
sinh(x)+cosh(x) — equals e^x
tanh(x)
Utility macros
rad(x) — convert degrees to radians: x * 2 * pi / 360.
Float-only macro; auto-wrapped in from_float() when used in an Integer provider.
Example: sin(rad(90)) — sine of 90° (≈ 1)

deg(x) — convert radians to degrees: x * 180 / pi.
Float-only macro; auto-wrapped in from_float() when used in an Integer provider.
Example: deg(pi) — ≈ 180

grad(x) — convert gradians to radians: x * pi / 200.
Float-only macro; auto-wrapped in from_float() when used in an Integer provider.
Example: sin(grad(200)) — sine of 200 grad (≈ 0)

dgrad(x) — convert radians to gradians (inverse of grad): x * 200 / pi.
Float-only macro; auto-wrapped in from_float() when used in an Integer provider.
Example: dgrad(pi) — ≈ 200

sign(x) — sign function: returns 0 if x == 0, otherwise abs(x)/x (i.e. 1 or -1).
Available for both Integer and Float providers.
Implemented as a conditional with an inline minecraft:float_value_check predicate that checks if x equals 0.
Example: sign(x)
Symbolic differentiation f'(...)
f'(expr) — first derivative of expr with respect to x.
f''(expr) — second derivative.
f'{n}(expr) — n-th derivative (n ≥ 1, integer).

The expression is differentiated symbolically at parse time, then expanded into a number provider expression using the available operations. Differentiation is always with respect to the variable x; all other variables are treated as constants (derivative = 0).

Supported functions: sin, cos, tan, cot, sec, csc, sinh, cosh, tanh, sqrt, abs, negate, rad, deg, grad, sign, pow (constant exponent), add, sub.
Supported operators: +, -, *, /, ^ (constant exponent), unary -.
Custom functions are expanded before differentiation.

Examples:
f'(sin(x))cos(x)
f'(x^2)2*x
f''(sin(x))-sin(x)
f'{3}(x^3)6
f'(sin(x)*cos(x))cos(x)*cos(x)+sin(x)*(-sin(x))
Built-in constants
The following mathematical constants are recognized automatically in expressions (case-insensitive) and do not require a variable source — they map to minecraft:constant:

pi — π ≈ 3.141592653589793
e — Euler's number ≈ 2.718281828459045
tau — 2π ≈ 6.283185307179586
phi — golden ratio ≈ 1.618033988749895
sqrt2 — √2 ≈ 1.4142135623730951
sqrt3 — √3 ≈ 1.7320508075688772

You can also use the constant source type for any variable to assign a fixed numeric value (useful for named constants in your formula).

Example: sin(2*pi*x) — uses pi as a built-in constant.
Example: e^x — uses e as a built-in constant (same as pow(e,x)).
Type conversion (automatic)
Functions native to the opposite provider type are automatically wrapped:
• Float function in Integer provider → wrapped in from_float(...)
• Integer function in Float provider → wrapped in from_int(...)
Example: sqrt(x) as Integer → from_float(sqrt(x))
Example: binomial(4,0.5) as Float → from_int(binomial(4,0.5))
Conditional (predicates via Misode)
conditional(condition?on_true[;on_false]) or if(condition?on_true[;on_false])
— conditional value based on a predicate (→ minecraft:conditional)

condition can be one of:
Resource location (wrap in quotes): "minecraft:block/fast_cooking" — references a predicate defined in your datapack
Misode share URL (wrap in quotes): "https://misode.github.io/predicate/?share=VRMRftbVNM"
Share code (alphanumeric, no quotes): VRMRftbVNM
Inline JSON (no quotes needed): {"type":"minecraft:random_chance","chance":0.5}

You can create a predicate visually in the Misode Predicate Generator, then copy the share code or URL from there and use it here as the condition.

on_true (required) — number provider used when the condition passes.
on_false (optional) — number provider used when the condition fails; defaults to 0.

Both on_true and on_false can also be a quoted string referencing another number provider: "minecraft:cooking/fast_speed_multiplier".

Examples:
if(VRMRftbVNM?1;0)
conditional("https://misode.github.io/predicate/?share=VRMRftbVNM"?x;0)
if({"type":"minecraft:random_chance","chance":0.5}?1)
conditional("minecraft:block/fast_cooking"?"minecraft:cooking/fast_speed_multiplier";"minecraft:cooking/normal_speed_multiplier")

Number dispatcher (multiple conditions)
number_dispatcher[(cond1?val1),(cond2?val2);default]
— dispatch to different number providers based on predicates (→ minecraft:number_dispatcher)
Aliases: dispatch[...], nd[...]

cases — comma-separated list of (condition?value) pairs, each wrapped in parentheses.
condition — same formats as conditional(): resource location, Misode URL, share code, or inline JSON.
value — number provider used when the case's condition passes (can also be a quoted string reference).
default (optional, after ;) — number provider used when no case matches; defaults to 0.

Predicates are evaluated in order; the first matching case wins.
Create predicates in the Misode Predicate Generator.

Examples:
nd[({"type":"minecraft:weather_check","raining":true}?1),({"type":"minecraft:weather_check","thundering":true}?2);0]
dispatch[(VRMRftbVNM?x),(ABC123?y)]
number_dispatcher[({"type":"minecraft:random_chance","chance":0.5}?1);0]

Unsupported operations (not yet implemented)
enchantment_level — value based on enchantment level (float only)
Examples
Function Library

Create custom functions and constants. Functions are stored in your browser and can be used in expressions.

Result