parseInt() function in Javascript | HEX to RGB Color Code

Date Published: 10/09/2020 Published By: JaiSchool

This function converts the hex color value in RGB color format.

(Hex code: #00ff08) The first two letters (00) in hex code represent for red color, the middle two letters (ff) are for green color and the last two letters (08) represent for blue color.

Use parseInt() function to produce RGB value from HEX. Its first parameter contains-

  • two digit of hex code, and
  • the second parameter needs a predefined value 16 (sixteen).


<!DOCTYPE html>
  <title>HEX TO RGB</title>

		var red=parseInt("00",16);
		var green=parseInt("ff",16);
		var blue=parseInt("08",16);
		var rgb="rgb("+red+","+green+","+blue+")";

Publish A Comment

Leave a Reply

Your email address will not be published. Required fields are marked *