I get colored tree using tree -C but when I pipe it to less I get results like this:
tree public/ -C | less

How can I have colors in less in this case?
You want the -R switch to less.
From the less man page:
-R or --RAW-CONTROL-CHARS Like -r, but only ANSI "color" escape sequences are output in raw" form. Unlike -r, the screen appearance is maintained correctly in most cases. ANSI "color" escape sequences are sequences of the form:
ESC [ ... m
So you need
tree -C public/ | less -R
Passing -r to less will tell it to pass through control characters and escape sequences unmolested.