Skip to main content

Free Algorithm Visualizer

Watch sorting, pathfinding, and classic algorithms come to life โ€” bubble/quick/merge sort, Dijkstra/A*/BFS on an interactive maze grid, plus binary search, the Sieve, N-Queens and Game of Life. Step-by-step animation, synchronized pseudocode, live metrics, and a side-by-side race mode. Mobile-friendly and 100% in your browser.

Runs entirely in your browser โ€” no data leaves your device.

Common uses

  • Bubble Sort VisualizerWatch bubble sort step by step โ€” see how it compares and swaps neighbours, with synchronized pseudocode and live comparison/swap counts. Runs in your browser.
  • Quicksort VisualizerSee quicksort partition an array around a pivot in real time, with the pivot highlighted, synchronized pseudocode, and live metrics. 100% in your browser.
  • Merge Sort VisualizerVisualize merge sort splitting and merging sorted halves, with synchronized pseudocode and live array-write counts. Guaranteed O(n log n), stable.
  • Heap Sort VisualizerWatch heapsort build a max-heap and repeatedly extract the largest element, with synchronized pseudocode and live metrics. In-place, O(n log n).
  • Insertion Sort VisualizerSee insertion sort build a sorted section one element at a time, sliding each value into place โ€” with synchronized pseudocode and live counts.
  • Selection Sort VisualizerWatch selection sort scan for the minimum and swap it into place each pass, with synchronized pseudocode and live comparison/swap counts.

How It Works

Every algorithm is written as a generator that yields one visualisation "step" at a time โ€” a snapshot of the array plus which elements were compared, swapped or written. A single player pre-computes the full step list, so play, pause, step-forward, step-back and the side-by-side race mode are all just indexing into that list. Nothing is sent anywhere โ€” the whole thing runs in your browser.

  1. 1
    Pick an algorithm and a data set
    Choose from bubble, selection, insertion, merge, quick, heap, shell, cocktail, counting and radix sort (plus bogosort, for fun). Generate a random, nearly-sorted, reversed or few-unique array, or type your own comma-separated numbers.
  2. 2
    Watch it run โ€” and read along
    Bars are coloured by what is happening (comparing, swapping, pivot, sorted). The pseudocode panel highlights the exact line being executed, and live counters track comparisons, swaps, writes and array accesses in real time.
  3. 3
    Control time
    Adjust the speed, scrub the timeline, or step a single operation forward and back to study exactly how the algorithm makes its decisions. Step-back is exact because each step is a stored snapshot, not a re-run.
  4. 4
    Race them head-to-head
    Race mode runs two or more algorithms on the same input at once, side by side, with a metrics table so you can see, for example, why quicksort beats bubble sort.

Runs entirely in your browser โ€” no data leaves your device. There is no server, no upload, and no account. It is a teaching tool: the algorithms are textbook implementations chosen for clarity of visualisation.

Guide

Worked example

Open the Sorting tab. In "Custom numbers or words" type 5, 3, 8, 1 and press "Apply". "Size: 4" appears and four labelled bars replace the 40 random ones. "Bubble Sort" is selected, and the "Timeline" reads 1/14. Press "Play". When the run ends, the timeline reads 14/14, the bars read 1, 3, 5, 8 in the "Sorted" colour, and the counters show Comparisons 6, Swaps 4, Writes 8 and Accesses 12. Now click "Selection Sort" with the same data. It takes 18 steps with Comparisons 6 but only Swaps 2, because selection sort swaps at most once per pass. Type banana, apple, cherry and press "Apply" to sort words instead. "Share this run" copies a link that reopens this algorithm, this data and the step you are on. "Save image (PNG)" saves the current frame, for example as bubble-sort-step-14.png.

Which settings to use, and the limits

  • Pick an algorithm, then a starting shape. The Sorting tab has Bubble Sort, Selection Sort, Insertion Sort, Merge Sort, Quicksort, Heapsort, Shell Sort, Cocktail Shaker, Counting Sort and Radix Sort (LSD). "Add Bogosort (for fun)" adds an eleventh. The shape buttons are "Random", "Nearly sorted", "Reversed" and "Few unique". The "Size" slider runs from 2 to 120 and starts at 40 on a computer or 15 on a phone, and "Shuffle" makes new data. Changing the algorithm keeps the same data, so you can compare the runs fairly.
  • Learn the playback controls. Use "Play"/"Pause", "Step back", "Step forward" and "Restart", or drag the "Timeline" to any step. "Speed" is in steps per second, from 1 to 240, and starts at 30 on a computer or 20 on a phone. Because the whole run is worked out first, stepping backwards is exact. The shortcuts are Space, Left and Right arrows, R, and [ and ] for speed; they are ignored while focus is on a button, slider or text box. The first run starts by itself once, and playback pauses when you switch tabs.
  • Type your own numbers or words. "Custom numbers or words" needs at least two items, separated by commas or spaces. Numbers are rounded to whole numbers. If any item is not a number, every item is treated as a word and sorted alphabetically. Only the first 120 items are used, and labels show on the bars when there are 30 or fewer. Counting Sort makes one slot for every value between the smallest and the largest, so a list such as 1, 50000000 asks it for 50 million slots. Keep numbers for that algorithm in a small range.
  • Read the counters as well as the animation. The panel shows Comparisons, Swaps, Writes, Accesses, Step and Compute time, counted up to the step you are on. Counting Sort and Radix Sort make no comparisons, so that box is hidden for them. "Compute time" is how long this browser took to work out the steps, not a speed test of the algorithm. "Measure growth" under "How the work grows with size" runs every sorting algorithm except Bogosort on random arrays of 10, 25, 50, 100, 250 and 500 items, and "Download results as CSV" saves sorting-growth.csv.
  • Race algorithms and share what you find. "Race mode" lets you pick 2 to 4 algorithms to run on the same data at the same step rate. The one with the fewest total steps finishes first and gets the trophy mark, and "Back to single view" returns you. Steps are not seconds, so this shows how much work each method does rather than how fast it runs on your computer. Bogosort cannot be raced. Outside race mode, "Share this run" copies a link that opens at the same step, paused.
  • Switch tabs for pathfinding and the classic algorithms. "Pathfinding" has Breadth-First Search, Dijkstra, A* Search, Greedy Best-First, Bidirectional BFS and Depth-First Search on a grid of 16 rows by 30 columns, or 18 by 13 on a phone. Drag to draw walls and drag the green start or red goal. In "Weights" mode a cell costs 5; only Dijkstra and A* use weights. "Classic" has Binary Search, Linear Search, Sieve of Eratosthenes (n from 20 to 120), N-Queens (N from 4 to 10), Game of Life and Fisherโ€“Yates Shuffle (size 8 to 60).

Common problems and how to fix them

It says "Enter at least two numbers or words, separated by commas."
The custom box found fewer than two items. A single number, an empty box, or only commas and spaces all trigger it, and the box gets a red outline. Add a second item and press "Apply" or Enter. Spaces work as separators too, even though the message mentions commas. Text such as 5 3 x is not an error: it is read as three words.
It says "Bogosort is factorial-time, so it's capped at 7 elements โ€” anything larger could run effectively forever."
You added Bogosort with "Add Bogosort (for fun)" and selected it. It shuffles at random until the list happens to be sorted, so the "Size" slider stops at 7, the data is cut down to 7 if it was larger, and a custom list is trimmed to its first 7 items. Choose another algorithm to go back to sizes up to 120.
It says "No path โ€” the goal is walled off."
This appears on the Pathfinding tab when the run finishes without reaching the goal, because walls enclose it or the start. "Random walls" can do this by chance. Drag the goal or start to an open cell, or press "Clear walls", which also removes weights. "Clear path" only rewinds the run to step one and keeps your walls.
The "Share this run" button changes to "Copy failed".
The browser blocked the clipboard, which can happen in an embedded frame or without permission. The link is normally also put in the address bar, so you can copy it from there. The link covers the Sorting tab only, and it holds the algorithm, up to 120 items and the step number. Pathfinding and Classic runs cannot be shared this way.
The animation does not start, or it stops by itself.
The first run starts on its own only once, and not at all if your device asks for reduced motion, so press "Play". Playback also pauses when the tab is hidden, and it stops at the last step; pressing "Play" there starts again from step one. Keyboard shortcuts do nothing while a button, slider or text box has focus, so click an empty part of the page first.

How it compares

Use this to see why an algorithm behaves the way it does: you can step forwards and back, watch the pseudocode line, and compare counts on identical data. It is not a benchmark. The counts come from this tool's own step-by-step versions of each algorithm, not from the sort in your programming language, and Compute time only measures how long the browser took to prepare the steps. It has 10 sorting algorithms (11 with Bogosort), 6 pathfinding algorithms and 6 classic ones, but you cannot paste in your own code, load a real map, or sort more than 120 items. Everything runs in your browser and nothing is sent anywhere.

Related Tools

Frequently Asked Questions