QLCodePreview
Quick Look extension · macOS
QLCodePreview
Space-bar any source file in Finder and see it colourised. A Quick Look preview extension built on the app-extension API, now that Apple has retired the `.qlgenerator` plugins the old tools relied on.
macOS 12+ Universal · arm64 + Intel free · donationware
Get QLCodePreview → Buy me a coffee ↗
Learn about QLCodePreview's development at briangilbert.net ↗
main.swift · Quick Look
1
// main.swift, colourised
2
func preview(for file: URL) throws -> QLPreviewReply {
3
let source = try String(contentsOf: file, encoding: .utf8)
4
let html = Highlighter.shared.render(source)
5
return QLPreviewReply(dataHTML: html)
6
}Highlights
Nothing on this list is a roadmap. It's all in the current build.
Self-contained
The highlighter is built from scratch and runs inside the sandboxed extension. Nothing to install alongside it.
Fast
A 2 MB file previews in about 130 ms: keyword lookup is a set scan, and each colour crosses the wire once as a CSS class, not once per token.
Tunable
Font and size, light and dark themes, line numbers, soft-wrap, tab width, and a max file size past which it won't render.
Bring your own file types
Map any file extension to a language in settings; install → php is the canonical example. The Drupal filetypes that started this whole thing in 2012 are a settings tab now, not a fork.
Languages
Source, config, markup: dozens of languages, and anything unknown falls back to plain text.
SwiftCObjective-CC++RustGoZigNimJavaKotlinScalaGroovyClojureC#F#Visual BasicJavaScriptTypeScriptPHPCSSSCSSSassLessStylusVueSvelteXMLXSLTSVGJSONYAMLTOMLINIMakeCMakeGraphQLTerraformSQLMarkdownAsciiDocreStructuredTextLaTeXPythonRubyPerlLuaTclShellPowerShellRDartElixirErlangHaskellPascalJuliaCrystalDiffPlain text
The full extension map
| C family | | | ------------------- | ------------------------------------------------------------------------------------------------------------------------ | | C | .c | | Objective-C | .h, .m | | Objective-C++ | .mm | | C++ | .cpp, .cc, .cxx, .c++, .hpp, .hh, .hxx, .h++, .ino | | Apple / systems | | | Swift | .swift | | Rust | .rs | | Go | .go | | Zig | .zig | | Nim | .nim | | JVM | | | Java | .java | | Kotlin | .kt, .kts | | Scala | .scala, .sc | | Groovy | .groovy, .gradle | | Clojure | .clj, .cljs | | .NET | | | C# | .cs | | F# | .fs | | Visual Basic | .vb | | Web / JS | | | JavaScript | .js, .mjs, .cjs, .jsx | | TypeScript | .tsx | | PHP | .php, .install, .module, .engine | | CSS / preprocessors | .css, .scss, .sass, .less, .styl | | HTML | .vue, .svelte | | XML | .xml, .xsl, .xslt, .xsd, .rss, .svg, .resx, .csproj, .plist, .iml, .fxml, .rdf | | Scripting | | | Python | .py, .pyw, .pyi | | Ruby | .rb, .rbw, .gemspec | | Perl | .pl, .pm, .t | | Lua | .lua | | Tcl | .tcl | | Shell | .sh, .bash, .zsh, .ksh, .csh, .tcsh, .fish, .command, .bashrc, .zshrc, .bash\_profile, .profile, .bats, .ebuild, .eclass | | PowerShell | .ps1, .psm1 | | Data / config | | | JSON | .json, .json5, .jsonl | | YAML | .yaml, .yml | | TOML | .toml | | INI / config | .ini, .cfg, .conf, .properties, .editorconfig, .gitconfig | | Build / infra | | | Make | .mk, .makefile, .gnumakefile, .am | | CMake | .cmake | | GraphQL | .graphql, .gql | | Terraform | .tf, .tfvars | | Database | | | SQL | .sql, .psql, .ddl | | Docs / markup | | | Markdown | .md, .markdown, .adoc, .asciidoc, .rst | | LaTeX / TeX | .tex, .latex | | Other languages | | | R | .r | | Dart | .dart | | Elixir | .ex, .exs | | Erlang | .erl, .hrl | | Haskell | .hs, .lhs | | Pascal | .pas, .pp, .dpr | | Julia | .jl | | Crystal | .cr | | Misc | | | Diff / patch | .diff, .patch, .rej | | Plain text | .txt, .log, .diz, .nfo, .sfv, .readme |
Unknown extensions fall back to plain text, and any extension can be remapped in the app's Custom File Types pane.
Get it
Donationware, and installing is one command.
1. 1
Install it
The easy way is Homebrew: `brew trust konstruukt-labs/tap` (one-time; current Homebrew requires it for third-party taps), then `brew install --cask konstruukt-labs/tap/qlcodepreview`. Or grab the latest notarised build from GitHub ↗. It's a universal zip (arm64 + Intel), built and tested on Apple Silicon. Building from source works too: `./build.sh install` needs nothing but Apple's Command Line Tools, no Xcode. 2. 2Flip the switch
Run QLCodePreview once (the toggle only appears after the app has been run), then System Settings → General → Login Items & Extensions → Extensions → QLCodePreview = ON. The one step macOS won't let a script do. 3. 3Space-bar something
Any source file in Finder, colourised on the spot.Support development
The app is free, but making it isn't: Apple Developer Program membership and everything hosted around the app cost real money. If QLCodePreview earns its keep on your Mac, there's a coffee link in the app's footer, or the button right here.
