random string to css color

2013 by @TimPietrusky

Fork me on GitHub

randomstringtocsscolor.com

How does this work?

  1. Change each non-hex character to a 0.
  2. Add 0's to the string until its length is a multiple of 3.
  3. Divide string into 3 equal parts.
  4. While the length of the sub-strings is greater than 2, and all three of the sub-strings begin with a 0, remove the leading 0s from each string.
  5. If the length of the sub-strings is still greater than 2, then truncate each substring to 2 characters.
Source: Why do weird things in font color attribute produce real colors?