I want to use code in an inDesign document, and for that to be easily readable and pretty, I am looking for a way to get a syntax highlighting as in texteditors like notepad++, Sublime Text and Atom.

Since I need real syntax highlighting (so that, for example, different data types are depicted with different colors), it is not sufficient to assign colors to certain characters (like the brackets). Also it would be nice if I could manually change in which color certain elements are depicted, but that's not absolutely necessary. Since I want to use different code types (mostly HTML, CSS and Javascript), it would be too much work to manually assign parameters on when to highlight what, so I need something that has presets for at least the three languages mentioned above.

Of course, I could use screenshots, but I don't want that since the code should be copyable (is this even a word? LOL) ...

So, is there a way to either get the syntax highlighting from the texteditors mentioned above into inDesign or achieve a similar effect in inDesign itself?

  • 4
    GREP styles may be enough -- you can easily colorize keywords, numbers, and HTML codes. Strings are a bit harder if your code is using a free-for-all approach (the easiest case is just ".*?"). But it will not pick up multiple line comments.
    – Jongware
    Sep 20, 2014 at 12:41
  • What will your final output be? If you want it to be copyable, why are you using InDesign? Are you outputting to PDF? Jun 20, 2016 at 14:58

2 Answers 2


Use something like,

  • Highlight, the command line version may be a good idea,
  • Scite, open and export (can also be used via cmd),
  • any of the JavaScript code highlighters,
  • etc.

to convert your code into RTF or HTML with styles then place that into InDesign.


I think the closest you could get with having something automated inside InDesign would be using Paragraph Styles with Character Styles nested inside them. However, this will be pretty limited since it expects a consistent linear form such as A B C, and depending on your code, you may often have A C C B.

To my knowledge, InDesign has no means of accomplishing the more granular syntax highlighting that would be required for this. If I absolutely had to do this natively in InDesign, I would probably assign shortcut keys to some Para/Chara Styles, and do it manually.

If you are good with code, you could probably write something to generate an IDML file for each block of code, which you could then File > Place in to your document and the appropriate syntax highlighting would come in with it (if you'd figured out a way to generate the IDML properly).

  • 1
    Thank you for these suggestions, but I think neither will work for me. As you said, the nested character styles are to limited to create real syntax highlighting. And I'm not that much of a coder ... admittedly, XML is not sooo complicated, but 500 pages of documentation to learn the inDesign XML Syntax is a bit too much work for my purposes °ω°"""
    – MoritzLost
    Sep 20, 2014 at 13:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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