@oli's answer relies on you being able to provide appropriate flags to the command that produces the colors. That can be difficult if commands are buried in scripts and the like, and it requires working out how to provide appropriate flags separately for various commands that know how to produce ANSI escapes when the terminal environment says they can.
@DaveEmme's answer tells you that you can use lesspipe to colorize output from whatever source, but as far as I know it won't retain the color from commands that already produce it when output goes to the terminal.
If you already have a command that works just fine in your terminal, then it's nice to be able to run that command in such a way that color escapes are kept regardless of the output being piped, so you can feed that into
unbuffer does this for you. On debian at least you get it with
sudo apt install expect-dev.
You can then do:
unbuffer [command] |& less -R
|& instead of
| might be an unnecessary detail, but it means STDERR gets piped to less as well as STDOUT.
Thanks to https://superuser.com/a/1260695/229226 for this.