All toolsDFS Visualizer

Developer tool

DFS Visualizer

Watch Depth-First Search follow one branch as far as possible before backtracking across the grid.

Search
Board
Speed
Edit grid

About this tool

How DFS explores

Depth-First Search prioritizes depth over distance. The animation shows how its stack-driven traversal commits to a route, then backtracks when that route ends or cannot reach the goal.

Try a maze with multiple corridors to see why the first path DFS finds is not necessarily the shortest. Compare its route with BFS on the same unweighted grid.

How it works

Try this visualizer

  1. 1Set up the grid

    Draw walls or weighted cells, then place the start and goal nodes.

  2. 2Run the algorithm

    Use DFS to study graph traversal, backtracking, and the trade-off between fast discovery and path quality.

  3. 3Compare the outcome

    Use the links above to run another algorithm against the same kind of map.

Common questions

DFS Visualizer FAQ

Can I draw my own obstacles?

Yes. Choose Wall, Weight, Erase, Move start, or Move goal, then drag across the grid before running the selected algorithm.

Do weighted cells change every algorithm?

Weighted cells change the displayed path cost for every run, but only Dijkstra's and A* use those costs when choosing their route.

Does the visualizer run in my browser?

Yes. The grid and every search run stay in your browser; nothing you draw is uploaded or stored.