Is there a easy way to insert source code with highlight in Google Docs?


Not directly but there is an easy way to do it.

You can use the online Colorer-take5 HTML generator to produce the highlighted code. Afterwards just copy/paste it into your document, but don't forget to change the font to Courier New and probably reducing the size of it and you're done.

Here is an example for Java code and using the Eclipse style: alt text

| improve this answer | |
  • 8
    Great idea, but I would suggest pygments.org to generate colored HTML (with multiple styles) and Consolas as font. – schlamar Dec 12 '12 at 21:33
  • I used Microsoft word for this. Pasted my code in Microsoft word and then copy/paste in google docs – gogagubi Jun 15 '19 at 12:19

With the new Add-Ons for Google Drive, you can get code highlighting with the Code Pretty add-on.

After installing it, you can access the add-on by clicking Add-ons → Code Pretty, → Format Selection:
Screenshot of using the add-on

This results in:
Result of using the add-on

| improve this answer | |
  • 4
    This is a much better answer! – jackocnr Sep 18 '14 at 22:58
  • 3
    It is but in defense of @Lipis he answered back in 2010. – Asken Mar 5 '15 at 6:29
  • Doesn't support code on dark background – Igor Vaschuk Jun 6 '16 at 20:42
  • 1
    @IgorVaschuk, for me it does (for instance, I use PyCharm with the Darkula theme). I just need to cancel the highlighting in the google doc. – nullgeppetto Oct 17 '16 at 21:21

Not the answer you're looking for? Browse other questions tagged or ask your own question.