JSVisualizer is a web app for learning how a JavaScript program runs step by step, by watching it through a variety of visualizations.

1. Screen layout

The screen in Run mode: stepping buttons and a slider at the top, highlighted code on the left, view tabs and the console on the right
The screen in Run mode
AreaContents
TopThe Edit and Run buttons, the sample selector (in Edit mode), and the stepping buttons and slider (in Run mode). At the right end: user manual (?), display language (EN / 日), and settings (⚙)
Left (Source)The code. You can edit it in Edit mode; in Run mode it highlights where execution currently is
RightThe visualization views. Switch between them with the tabs at the top; a one-line description of the current view appears below the tabs
Bottom right (Console)Output from console.log(). It stays visible whichever view is selected

Drag the border between the left and right panes to resize them. Drag the top edge of the console to change its height.

2. Preparing code

When you first open the app, it contains a sample program (the Fibonacci sequence).

Choosing a sample

In Edit mode, pick one of 21 sample programs from the sample selector (drop-down) at the top of the screen.

The screen in Edit mode: Edit and Run buttons and the sample selector at the top, bubble sort code on the left
Edit mode (with the “Bubble Sort” sample selected)
CategorySamples
SearchLinear Search, Binary Search
Sort (basic)Bubble Sort, Selection Sort
Sort (advanced)Quick Sort, Merge Sort
Sort (objects)Sort by numeric key, Sort by string key
Math / AlgorithmsEuclid GCD (loop / recursive), Factorial, Fibonacci (recursive / DP)
Data StructuresBinary Tree, Linked List
Scope / ObjectsClosure, Class & Inheritance
Study TasksTasks used in an evaluation study (finding a bug, counting calls, tracing intermediate state, etc.)

Writing your own code

In Edit mode you can freely edit the code on the left, or paste in code written elsewhere. When you are done, press “▶ Run”.

Opening a shared link

If you open JSVisualizer from a link that points to specific code (for example, one handed out in a class or in course materials), the app starts with that code loaded. The sample selector then lists only the linked code instead of the built-in samples (and cannot be changed when there is only one piece of code).

3. Edit mode and Run mode

ButtonDescription
✏ EditSwitches to Edit mode, where you can edit the code freely. The sample selector is available only in this mode
▶ RunRuns the code and switches to Run mode. The program runs to completion at once and every step is recorded. You can then use the stepping buttons to move forward and backward to any point and look at the state at that moment

After editing the code, press “Run” again to re-run it with your changes.

When an error occurs

If the code has a mistake, an error message appears below the code. The labels are in English, but the messages themselves are currently shown in Japanese only.

LabelMeaning
Syntax ErrorThe code cannot run because of how it is written (a missing bracket, a typo, etc.). Numbers such as 21:9 in the message are the line and column of the mistake
Runtime ErrorThe code is written correctly, but a problem occurred while it was running (using an undefined variable, etc.). You can still step through everything up to just before the error
Line 21 of the code has a mistake; a Syntax Error badge and message appear below the code
A syntax error

If execution exceeds 10,000 steps, it is stopped and reported as a runtime error, since the program may be stuck (for example, in a loop that never ends). You can step through everything up to the point where it stopped.

4. Stepping

In Run mode, the buttons at the top let you move execution forward or backward one step at a time. There are four kinds of buttons, each moving by a different amount, and each has a “back” and a “forward” version.

The row of stepping buttons: start, end, Func, Human, Stmt, and Expr buttons, the slider, and the step counter
Stepping buttons (from the left: go to start, go to end, Func, Human, Stmt, Expr, the slider, and the step counter)

Four granularities

ButtonsGranularityOne press moves
◀ Expr / ▶ ExprFinestOne expression evaluation at a time. For a[j] > a[j + 1] it stops at the value of a[j], the value of a[j + 1], and then the result of the comparison. Use it to see the order in which an expression is computed
◁ Human / ▷ HumanMedium (start here)One meaningful change — the kind of thing a person would write down when tracing on paper: an assignment, an if condition, a loop condition or update, a function call, and so on
◀◀ Stmt / ▶▶ StmtCoarseOne statement at a time, skipping the detailed computation inside it
⏪ Func / ⏩ FuncCoarsestStraight to the next point where a function is entered or returns. Use it to follow the overall flow of recursive calls

If in doubt, step with “▷ Human”. Use “▶ Expr” only where you want more detail, and “▶▶ Stmt” or “⏩ Func” to fast-forward through loops and function calls.

Other controls

ControlDescription
⏮Goes back to the start (the beginning of execution)
⏭Goes to the end (where execution finished)
SliderDrag the handle to jump to any point
Step counter (e.g. 180 / 874)The current step out of the total, counted in the finest (Expr) steps

Keyboard shortcuts

You can also use these keys (upper-case letters mean holding Shift).

GranularityBackForward
Expr← or b→ or n
HumanHh
StmtVv
FuncFf
Start / EndHomeEnd

Keys 1–9 switch to the first to ninth view tab from the left.

5. Code highlighting

In Run mode, the code on the left shows where execution is with three kinds of marks.

MarkMeaning
Blue band (blue bar at the left of the line)The line being executed
Orange backgroundThe expression being evaluated
Purple dashed underlineWhile inside a function, the expression that called that function (the call site)
Bubble sort code with line 5 highlighted by a blue band and the call on line 14 underlined with a purple dashed line
Executing line 5. The function bubbleSort was called from line 14 (purple dashes)
Recursive fib code: the condition in orange, and the call site fib(n - 1) underlined with purple dashes
Evaluating the condition (orange). This call of fib came from fib(n - 1) (purple dashes)

6. Visualization views

The right side of the screen shows the program’s behavior in many different forms. Use the tabs at the top to switch among 12 views. Which view is easiest to understand depends on what you want to know, so try several and find the ones that work for you.

How the views are organized

The 12 views can be organized along two dimensions: what you look at and how time is shown.

What you look at falls into three groups:

How time is shown comes in two kinds:

What you look atOne momentWhole run
StateVariable valuesVariableExec Trace
Functions being calledCall StackLifetime
Contents of memoryMemory—
BehaviorComputing expressionsExprSubst
Running statementsControl FlowHeatmap
Calling functionsCall Tree—
Arrays and objectsArraysArraysExec Trace
ObjectsObjects—

Comparing the same thing in a “one moment” view and a “whole run” view deepens understanding. For example, to see how a variable changes inside a loop, check its current value in “Variable” while lining up the values of each iteration in “Exec Trace”.

Views of state

TabTimeContents
VariableOne momentA table of code lines (rows) × variables (columns). Each row shows the variable values when that line last ran; values that changed since the previous step are in bold orange. You can show/hide columns and reorder them by dragging
Exec TraceWhole runLists the steps where assignments, condition tests, and the like happened, in execution order from top to bottom, with the variable values at each step and whether each condition was true or false. For code that uses arrays, each step also shows a small diagram of the array and where variables such as i and j point, so you can compare iterations
Call StackOne momentShows all current variable values, grouped into the global scope and each function call in progress. Inside functions you can see that every call has its own variables
LifetimeWhole runWith time running horizontally and call depth vertically, shows each function call as a band from when it started to when it ended. Each band is labeled with the function name, its arguments, and that call’s variable values, showing how long arguments and local variables exist. The vertical dashed line marks the current moment
MemoryOne momentDraws variables (the stack) and the actual arrays and objects (the heap) separately, with arrows showing which array or object each variable refers to
Variable view: a table with line numbers and code snippets down the side and variables across the top
Variable
Exec Trace view: a table with, for each step, the line number, code, an array diagram, variable values, and condition results
Exec Trace
Call Stack view: the global frame and a frame for each fib call showing the value of n
Call Stack
Lifetime view: time runs horizontally and call depth vertically, with each fib call drawn as a stacked band
Lifetime
Memory view: stack variables on the left, a heap array on the right, and an arrow from the variable to the array
Memory

Views of behavior

TabTimeContents
ExprOne momentShows how the one-line expression being computed turns into its final value as its parts are replaced by values. Orange marks the part just replaced; bold blue marks the part computed next. Parts skipped by || or && stay as they are
SubstWhole runShows, from top to bottom, how recursive calls expand as each call is replaced by the expression it returns: fib(5) → fib(4) + fib(3) → …
Control FlowOne momentA flowchart connecting the lines that ran, with the current line emphasized. Loop-back flows are dashed orange lines and branches that never ran are grayed out
HeatmapWhole runShows how many times each line ran, as color intensity and “count so far / total”. The dots on the right show when each line ran, so lines repeated in loops stand out at a glance
Call TreeOne momentShows function calls as a tree. Each node shows arguments and the return value; dashed gray means not yet called, thick blue means running, and green means finished. The cost at the bottom left is the number of calls in that node’s subtree (including itself) — handy for checking how many times a recursive function is called
Expr view: parts of an expression being replaced by values, one row per step
Expr
Subst view: fib(5) expanding into fib(4) + fib(3) and so on
Subst
Control Flow view: executed lines as nodes stacked vertically and connected by arrows
Control Flow
Heatmap view: execution count and color intensity for each line, with dots showing when each line ran
Heatmap
Call Tree view: a tree rooted at fib(5) branching into fib(4) and fib(3) and so on
Call Tree

Views of arrays and objects

TabTimeContents
ArraysOne momentShows array elements as cells colored by value. For variables used as indexes, such as i and j, the element they point to is marked below the cells. Choose which arrays to show with the buttons at the top. To see an array over the whole run, use “Exec Trace”
ObjectsOne momentShows references between arrays and objects as a graph — well suited to linked lists and trees
Arrays view: array elements shown as cells, with the element pointed to by an index variable marked
Arrays
Objects view: three linked-list nodes connected by next arrows, plus the array result
Objects (the “Linked List” sample)

The tab order differs from the grouping above (from the left: Call Stack, Variable, Exec Trace, Subst, Expr, Arrays, Heatmap, Call Tree, Lifetime, Control Flow, Memory, Objects). This organization follows Table 1 of Tanaka & Ueda, “Proposal for Program Execution Environment that Visualizes Program Behavior Using Multiple Views” (IS-26-049).

7. Other features

ButtonDescription
? at the top rightOpens this manual (in Japanese or English, matching the display language)
EN / 日 at the top rightSwitches buttons and tabs between English and Japanese
⚙ at the top rightSwitches between the light and dark themes. “Session Log” at the bottom of the settings panel is a feature for evaluation studies and is not needed in normal use (it records only inside your browser and can save the log as a JSON or CSV file)

The theme, language, pane widths, console height, and last-used tab are saved in your browser and restored the next time you open the app.

8. Troubleshooting

ProblemWhat to do
The stepping buttons are not shownYou are in Edit mode. Press “▶ Run”
The sample selector is not shownYou are in Run mode. Press “✏ Edit”
The sample selector cannot be changedYou opened a link to a single piece of code. To use the built-in samples, open https://tntetsu.github.io/JSVisualizer/ again
A Runtime Error says execution was stopped because it exceeded the maximum number of steps (10,000; the message is in Japanese: 「実行が最大ステップ数 10,000 を超えたため停止しました」)A loop or recursion may never end. Step through up to where it stopped and check the exit condition. If the program simply does a lot of work, use smaller data
Keyboard shortcuts do not workIf the cursor is in an input area such as the code editor, keys go there. In Run mode, click somewhere else on the screen first
A tab is grayed outThat view cannot be used with this code (e.g., “Subst” and “Call Tree” for code without functions)
The screen does not display correctlyUse an up-to-date desktop browser; reloading the page may help (smartphones are not supported)