Online Tool Store Online Tool Store

Recursion Tree Visualizer

Enter an input for factorial, Fibonacci, or a simple sum recursion and visualize the full recursive call tree, including each call's return value and evaluation order.

🔒 This tool runs entirely in your browser. Your files are never uploaded to a server.

Keep the input small (≤ 8) — recursive trees grow exponentially and a large input renders a huge diagram.

How it works

  1. Pick a recursive function — Fibonacci, factorial, or a simple sum — and an input value n.
  2. The tool walks the recursion exactly as the function would, recording each call as a node and each nested call as a child.
  3. The resulting tree shows every call's label, its computed return value, and how many total calls were made.

FAQ

Why is the input capped at 8?

Naive Fibonacci recursion grows exponentially — fib(8) already makes 67 calls, and fib(20) would make over 20,000. Capping n keeps the diagram readable and the page responsive.

Why does fib(n) branch into two calls but fact(n) only branches into one?

Fibonacci's recurrence relation references two smaller subproblems (n-1 and n-2), so every call spawns two children. Factorial and simple summation only ever reference one smaller subproblem, so their call trees are really just chains.

What does the call count tell me?

It's the total number of times the function was invoked to compute the result — a rough proxy for how expensive naive recursion is compared to a memoized or iterative version of the same function.

Visual tree vs. a debugger's call stack

Feature This visualizer IDE debugger step-through
See the whole tree at once
Debug your own actual source code

Great for building intuition before a CS class or interview; step through your actual code in a debugger to verify real behavior.

Explore related tools

Embed this tool

Paste this on your own site — it stays free, and every file still stays in your visitor's browser, not yours or ours.