I am looking for an OS X application to nicely format and print source code from a variety of programming languages.

  • Line numbers would be nice
  • Constant width font
  • Printing the contents of the clipboard would be a real plus

Does something like this exist (besides the obvious programmers' editors), free or reasonably priced?

  • Why is it a big deal to print the contents of the clipboard? Just save as a temporary file. In any case some formatters need the file extension to infer the language
    – smci
    Commented Dec 11, 2017 at 2:38
  • Do you want recognition of keywords, strings, constants, comments? Bold, italic? Colors? Configurable colors? PS output? PDF output? Configurable font size? Headers/footers? Duplex and n-up printing?
    – smci
    Commented Dec 11, 2017 at 2:39

5 Answers 5


You will find a nice answer over at sister site superuser. It involves a terminal program called enscript which comes with lot's of options and I know at least of one support file for extending its capabilities to print Ruby code.


I just noticed the "clipboard" part of the question. The clipboard content can be accessed from the command line and fed to enscript using pbpaste as mentioned in Matteo answer.

  • Presumably you need to find and install this, because it's not in my path on OS X. Commented Aug 4, 2020 at 3:48

If you don't want to use the terminal for this task and want a mac 'application' you should look at 'Text Wrangler' by Bare Bones Software. It is freeware, which fits your 'low price' request ;)

I use it to print out smaller runs of text, and use it specifically for the line number feature.


If you are familiar with the command line you could use a2ps (free and open source) which can be installed via MacPorts (install MacPorts and then sudo port install a2ps) or Homebrew (install Homebrew and then brew install a2ps).

For example:

a2ps -1 --line-numbers=5 -g source.c

will print source.c with syntax highlighting (-g) and line numbers each 5 pages. See the manual page for additional options. It supports a wide variety of source formats.

To print the content of the clipboard:

pbpaste | a2ps -1 --line-numbers=5

pbpaste prints the content of the clipboard to standard output which is read by a2ps.

  • If open source apps dont work for you, I recommend TextMate from macromates.com
    – ICL1901
    Commented Jan 15, 2013 at 18:53
  • You can also get a2ps from Homebrew (mxcl.github.com/homebrew). Some people like it better than MacPorts.
    – chrish
    Commented Jan 16, 2013 at 17:53

See also GNU Source-highlight, which supports many input languages and several output formats.


Do it online on https://carbon.now.sh/ or on https://github.com/jaredpetersen/codeprinter. The latter can be run locally too.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .