How-to

How to Preview Code and Markdown Files on a Mac — in Colour

Updated August 25, 2026

Select a .swift, a .php or a .py on a Mac and the preview is black text on white. It is readable, and it is nothing like how you read code everywhere else.

ComfortFiles colours it. In the side panel, and larger under the space bar with line numbers.

Which files

About sixty extensions, all of them files macOS renders as plain text today: Swift, Objective-C, C, C++, C#, Java, Kotlin, Go, Rust, Ruby, Python, PHP, JavaScript, TypeScript, JSON, XML, CSS, SCSS, YAML, TOML, INI, shell scripts, SQL, Lua, Perl, R, Makefiles, Dockerfiles, diffs and patches.

Deliberately not included: .html, which macOS renders as a page — richer than its source; .svg, which is a picture; and .txt, .csv and .rtf, where there is nothing to colour.

The wrap switch

Beside the file name, one button. Off, a long line runs off the edge and the preview scrolls sideways — the file as it is. On, lines wrap to the panel. The choice is remembered for next time.

Line numbers where they help

The space-bar window numbers its lines; the side panel does not. The panel is a strip beside a file list — it already prints the line count under the name, and the numbers would cost width the code needs.

The numbers are drawn rather than written into the text, so selecting the preview and pasting it gives you the code and not a column of digits.

Markdown as a document

A .md renders as the document it describes: headings, lists, tables, block quotes, code blocks with their own colouring, and working links. A link to another file opens that file; a link to the web opens your browser.

Nothing runs, nothing leaves

The colouring happens inside the app, with no network of any kind. The view that draws the page has JavaScript switched off, and every character of the file is escaped before it is drawn — a <script> tag inside a .js shows up as the characters <script>, which is the only correct way for a file manager to display a file it was handed by someone else.

  • The preview panel — everything else the panel shows and tells you.
  • Quick Look — the space-bar preview, and what it does for other kinds of file.

Frequently asked questions

How do I preview a code file with syntax highlighting on a Mac?

Select it in ComfortFiles. The side panel (⇧⌘P) shows it in colour, and Space opens the same file larger with line numbers. Around sixty kinds of source file are recognised — Swift, PHP, Python, JavaScript, TypeScript, Go, Rust, Ruby, Java, C, SQL, YAML, JSON and more. Nothing is installed and nothing is sent anywhere.

Why does macOS show my code as plain black text?

Because the system’s own text preview has no colouring — it renders any text file the same way. The coloured previews people see in screenshots usually come from a third-party Quick Look extension they installed themselves. ComfortFiles does the colouring itself, so it looks the same on every Mac without anyone installing anything.

Can I wrap long lines instead of scrolling sideways?

Yes — the switch sits beside the file name in the panel. Off by default, because a line of code broken to fit a narrow panel is a lie about the file; on when you would rather read the whole line. The choice is remembered.

Does the space-bar preview show line numbers?

Yes, in the space-bar window, drawn beside the code rather than written into it — so selecting the preview and copying it gives you the code, not code with a column of digits down the left. The side panel has no numbers on purpose: it is a strip beside a file list and already prints the line count underneath.

What about Markdown files?

They render as documents — headings, lists, tables, links and code blocks — in the panel and under the space bar, rather than as a page of hashes and asterisks. Links inside a document work: one to another file opens it, one to the web opens your browser.

Is my file sent anywhere to be highlighted?

No. The colouring happens inside the app, offline, and the preview cannot run anything the file contains: JavaScript is switched off in the view that draws it, and every character of the file is escaped, so a script tag inside a .js renders as the characters it is made of.