Printing In Colors

I don’t think there is an official way of doing it. But you can try to use ANSI escape codes to tell your console that a text should be colored (most terminals support it, including IntelliJs terminal & output).

// Everything after this is in red
val red = "\u001b[31m"

// Resets previous color codes
val reset = "\u001b[0m"

println(red + "Hello World!" + reset)

Pretty sure there are also 3rd party libraries that allow you to use colors.

See also: ANSI EscapeCode

1 Like