How to Add Colors to JavaScript Console Outputs ? Last Updated : 28 Apr, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report To Add Colors to JavaScript Console Outputs, we have multiple approaches In this article, we will learn to Add colors to Javascript console outputs. Below are the approaches used to add Colors to JavaScript Console Outputs: Table of Content Using %CUsing ANSI escape code Approach 1: Using %CThe %c placeholder is a special syntax that enables the application of CSS styling to specified sections of the console output. It allows programmers to format console messages according to CSS principles, Syntax:console.log("%c GeeksforGeeks", "color:green;");Example: In this example, we are using the above-explained approach. JavaScript let outputColor = "color:green; font-size:20px;" console.log("%c GeeksforGeeks", outputColor); console.log("%c A computer Science Portal", outputColor); Output: Approach 2: Using ANSI escape code The output color of the console can be modified via JavaScript using ANSI escape codes. Console messages can have their appearance changed to improve readability and visual distinctiveness by inserting escape sequences, such as '\x1b[36m%s\x1b[0m' for Green color. Syntax:console.log('\x1b[36m%s\x1b[0m', 'GeeksforGeeks');Example: In this example, we are using the above-explained approach to change our output color in the console. JavaScript console.log('\x1b[36m%s\x1b[0m', 'GeeksforGeeks'); console.log('\x1b[36m%s\x1b[0m', 'A computer science portal') Output: Comment More infoAdvertise with us Next Article How to add special characters to text to print in color in the console in JavaScript ? V vishalkumar2204 Follow Improve Article Tags : JavaScript Web Technologies Similar Reads Ways to Format Console Output in JavaScript In web development we use the browser's console window to display messages such as errors or warnings or even personalised methods. Mostly it is used by programmers for testing and debugging process. We can modify the console output according to our convenience to create personalised messages. We wi 1 min read How to convert rgb() color string into an object in JavaScript ? Given a color in the form of rgb( ) or rgba() and the task is to convert it into an object where the keys are the color names and values are the color values. Example:Input: rgb(242, 52, 110) Output: { red: 242, green: 52, blue: 110 } Input: rgba(255, 99, 71, 0.5) Output: { red: 255, green: 99, blue 2 min read How to Access Tailwind Colors from JavaScript ? Tailwind CSS is a "Utility first CSS framework". The feature that makes Tailwind has a variety of classes and provides a huge set of predefined colors that can be used in our stylesheets without the need to define them manually. These predefined colors are categorized into different color palettes w 4 min read How to add special characters to text to print in color in the console in JavaScript ? The purpose of this article is to add special characters to text to print in color in the console in JavaScript. Approach: The ANSI escape codes help change/specify the color of the output in the console. The color of the output of the console can be changed by adding these escape codes just before 2 min read How to Change the Color of HTML Element in JavaScript? Changing the text color of an HTML element using JavaScript enhances the user experience by making content more interactive and visually engaging. By accessing and modifying the element's style properties through the DOM, we can dynamically update font colors based on user actions or events. For exa 2 min read How to change text color depending on background color using JavaScript? The task is to set the foreground color based on the background color so that it will become visible. Here few of the important techniques are discussed. We are going to use JavaScript. Approach: First, select the random Background color(by selecting random RGB values) or a specific one.Use the YIQ 3 min read Like