Ruby, Generate a random hex color April 17, 2023 by Tarik Here’s one way: colour = "%06x" % (rand * 0xffffff)