JavaScript Rubik’s Cube Solver

We have written many articles about what can be done using only front-end coding without canvas. If we can draw an animated 3D cube with CSS3 then why shouldn’t we try to make a Rubik’s Cube solver with JavaScript?

Rubik's Cube solver website

What is the Rubik’s Cube?

Rubik's CubeThe Rubik’s Cube is the most famous puzzle toy that sold over 400K pieces since its invention in 1974. I’m sure that many kids will get one as a Christmas present this year, that’s the reason I’m writing about this topic.

The magic of the cube lies in its simplicity because the rules can be explained in a single sentence: turn the faces to make each face to be a solid color. But this is deciptive because soon you’ll realize that it’s almost impossible to solve it. It took one month for the inventor of the cube, Erno Rubik to figure out the solution.

Visit Ruwix, the Rubik’s Cube Wiki to find out more about this amazing puzzle and other twisty puzzles. You’ll be surprised to find that cubing is a sport and there are ever speedcubing competitions.

How does the Rubik’s Cube solver work?

Next I’m going to present an amazing online Rubik’s Cube solver program which can be tested at

It’s using JavaScript to calculate the solution of the Rubik’s Cube in 20 steps or less which is proved to be the optimal solution. Mathematicians have been looking for decades for the minimum amount of steps required that is enough to solve the cube from any valid starting position. Finally in 2010, this number proved to be 20 using 35 CPU-years of computer-time, donated by Google’s supercomputers.

The solver is using only HTML, CSS and JavaScript and it finds the result with the Cube Explorer algorithm written by Herbert Kociemba. Cube Explorer is an open-source, educational product, available for anyone who’s interested in the mathematics of the Rubik’s Cube.

The visitor has to color an unfolded cube to match the colors of his scrambled cube. Paste all 54 sticker colors and press the solve button. The program will take a few seconds to look for the solution and will display the step-by-step guide.
All you have to do now is follow the instructions to fix your cube.

The program can be used as a cube simulator. Press the scramble command and try to match the colors using the rotation buttons.

Cube Solver by Ruwix

Cube solver by Ruwix
I have mentioned before Ruwix, the Rubik’s Cube Wiki which is the best resource for learning about this puzzle. Even this site has got its Rubik solver which works the same but it has a slightly different user interface.

The Ruwix solver is using background images and not CSS3 transforms to render the faces of the cube.

This is a great resource if you want to learn how to solve the Rubik’s Cube without the help of a program. An easy to follow step by step guide is teaching the beginner’s method which can be learned in an hour.

How to use? Video

Watch the video tutorial on how to use the Rubik’s Cube solver:

how to use video