Bubble Sort Visualizer — Animated, Step-by-Step
Animated bubble sort with step controls, speed, custom input, live comparison/swap counters and pseudocode. Runs entirely in your browser.
Code examples
Ready-to-copy reference implementations. Free to use in your own projects and assignments.
How to use
- 1 Press Play to watch the array sort, or use Step to advance one comparison at a time.
- 2 Adjust Size for more or fewer bars, and Speed to slow the animation down.
- 3 Type your own numbers into Custom input and press Apply to sort a specific array.
- 4 Follow the highlighted pseudocode line and the live comparison / swap counters.
Why use this tool
- See exactly how adjacent comparisons and swaps bubble the largest value to the end each pass.
- Step forward and backward through every operation — no black box.
- Live metrics show why bubble sort is O(n²): comparisons grow with the array size.
- Runs entirely in your browser. No signup, no uploads.
Frequently asked questions
What is bubble sort?
Bubble sort repeatedly steps through the list, compares adjacent elements, and swaps them if they are in the wrong order. After each full pass the next-largest value is in its final position.
What is the time complexity of bubble sort?
O(n²) in the average and worst case because of the nested loops. Best case is O(n) when the array is already sorted — the optimized version detects no swaps and stops early.
Is bubble sort stable?
Yes. Equal elements keep their original relative order because it only swaps on a strict greater-than comparison.
When should I use bubble sort?
Almost never in production — it is a teaching algorithm. For real workloads use a built-in sort (Timsort / introsort). Bubble sort is valuable for understanding comparisons, swaps, and stability.
What is Bubble Sort Visualizer?
A Bubble Sort Visualizer is an interactive tool that animates the bubble sort algorithm, showing each adjacent comparison and swap as the largest values "bubble" to the end of the array. It highlights the active pseudocode line and counts comparisons and swaps so learners can see why bubble sort runs in O(n²) time.
Bubble Sort Visualizer is a free algorithm utility by Zerethon Tools. Animated bubble sort with step controls, speed, custom input, live comparison/swap counters and pseudocode. Runs entirely in your browser. Runs entirely in the browser — no signup, no upload.
- Category
- Algorithm
- Pricing
- Free
- Privacy
- Browser-based
- Signup
- Not required
Privacy
Your data never leaves your browser unless explicitly stated. Bubble Sort Visualizer runs entirely client-side — no server upload, no logging, no tracking of your input.
Related tools
Insertion Sort Visualizer
Animated insertion sort with step controls, speed, custom input, live comparison/write counters and pseudocode. Runs in your browser.
Open toolSelection Sort Visualizer
Animated selection sort with step controls, speed, custom input, live comparison/swap counters and pseudocode. Runs in your browser.
Open toolMerge Sort Visualizer
Animated merge sort with step controls, speed, custom input, live comparison/write counters and pseudocode. Runs in your browser.
Open toolQuick Sort Visualizer
Animated quicksort with pivot/partition highlights, step controls, speed, custom input, live counters and pseudocode. Runs in your browser.
Open toolBuild, share, and grow on Zerethon Social
Free signup. Earn points, collect achievements, and connect with creators worldwide.