Heap Visualizer

Paste an array, choose min heap or max heap mode, then visualize heapify, insert, and extract-root operations directly in the browser.

Nodes
9
Height
4
Minimum
9
Violations
0

Heap input

The heap is stored level by level in an array. The first 31 whole numbers are used.

Heap operations

Recent heap steps

Build, insert, or extract to see the swaps used to restore heap order.

Min heap diagram

Sample min heap loaded. Build, insert, or extract the root.

Swap Root
Heap diagramCurrent min heap stored as [9, 11, 27, 14, 21, 33, 60, 42, 18].9i=011i=127i=214i=321i=433i=560i=642i=718i=8

Heap array

0: 91: 112: 273: 144: 215: 336: 607: 428: 18

Index rules

For index i, left child is 2i + 1, right child is 2i + 2, and parent is floor((i - 1) / 2).

A valid min heap has 0 parent-child violations.

What is a Heap Visualizer?

A heap visualizer is an interactive tool that turns array input into a binary heap diagram. It is useful for understanding priority queues, heap sort, heapify, insert, and extract operations.

This tool supports both min heap and max heap mode. In a min heap, every parent is smaller than or equal to its children. In a max heap, every parent is larger than or equal to its children.

For the full set of related tools, browse the Data Structure Visualizers hub.

How to use this heap visualizer

  • Paste an array such as [42, 18, 33, 9, 21, 27, 60].
  • Choose Min heap or Max heap.
  • Click Build heap to heapify the array.
  • Insert a new value or extract the root to see how the heap changes.
  • Compare the tree diagram with the level-order array representation.

Binary heaps are usually stored as arrays. For a node at index i, the left child is at 2i + 1 and the right child is at 2i + 2.

Heap vs binary search tree

A heap is optimized for quickly finding the minimum or maximum value. It does not keep values fully sorted.

A binary search tree keeps smaller values on the left and larger values on the right. If you need search-tree ordering, use the Binary Search Tree Visualizer.

If you want to compare heap extraction with step-by-step ordering, try the Sorting Algorithm Visualizer.

Frequently Asked Questions

What input format does this heap visualizer use?
Paste whole numbers as an array, comma-separated list, or space-separated list. The tool keeps the first 31 values so the diagram stays readable.
What is the difference between a min heap and a max heap?
A min heap keeps the smallest value at the root. A max heap keeps the largest value at the root.
Does this tool show heap sort?
This page focuses on heapify, insert, and extract root operations. The extract operation is the core operation used repeatedly in heap sort.
Why does the array order change after heapify?
Heapify rearranges values so every parent-child relationship follows the selected heap rule. The result is a valid heap, not a fully sorted list.

Related tools