View all files | ||||
The application offers a Quick Look Extension for macOS 10.15 Catalina and later for previewing source files. Inside it uses Highlight to render source code with syntax highlighting.
Syntax Highlight is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY.
If you like this application and find it useful, buy me a coffee!
You can install the application in various ways. When the main application is launched it automatically checks for updates.
After installation, the application must be launched at least once to allow the system to detect the Quick Look extension. See below for instructions on how to enable the Quick Look extension.
Head over to the releases page to view the latest version. Move Syntax Highlight.app into the Applications folder.
Syntax Highlight can also be installed via Homebrew. If you have not installed Homebrew, follow the simple instructions here. After that, install the current version of Syntax Highlight with the following command:
The precompiled app is codesigned and notarized.
The release application is compiled as a universal binary (Intel and Apple silicon processor).
After cloning remember to fetch submodules:
To use the Quick Look preview you must launch the Application at least once. In this way the Quick Look Extension will be discovered by the system and will be available in the System preferences > Extensions > Quick Look.
The Quick Look Extension uses the Uniform Type Identifier (UTI) to handle the supported formats (and not simply the file name extension). Inside the definition on an UTI there are the list of extensions and mime type associated with it.
Some file types are directly associated to a UTI by the system. Other formats are registered by the owner application. In this way some extensions can be associated to multiple UTIs based on the applications currently installed. For this reason, this application supports many UTIs even if they are apparently redundant.
MacOS 10.15 Catalina does not allow to manage some file formats including (but not limited to): .xml, .plist, .html, .ts, .dart, .txt, common images (.jpg, .gif, .png), …
On macOS 11 Big Sur, the system allows you to manage these previously unauthorized extensions: .plist.
On macOS 12 Monterey, the system allows you to manage these previously unauthorized extensions: .xml.
Most programming languages are supported. The application can also handle some plain files without extension.
With the standalone application you can customize the rendering settings.
You can show advanced settings using the relative command on the view menu.
You can set the settings for all supported formats on the General tab.
| Render engine | Engine used to render the highlighted code. Before macOS 12 Monterey the recommended engine is RTF. Choose the HTML engine if you want to use a custom CSS to override the color scheme (or you have choose a theme with some extra CSS inside it). Advanced users must choose the HTML engine to handle the hover functionality of a Language Server. | |
| Color scheme | Chose the color scheme for light and dark appearance. | |
| Font | You can chose a preferred font or use the standard monospaced font. | |
| Word wrap | Allow to handle word wrap for long lines. Hard wrap break the line after a fixed length (can cause some highlight glitch). Soft wraps allow to break the line at the preview windows width. When word wraps is disabled, you can only enable it for minified files that have only one line. One line file detection is done on the source file and not on the preprocessor output. Starting from macOS 12 Monterey the soft wrap is always enabled when using the RTF engine. | |
| Line numbers | Allow to show the line numbers. | |
| Tabs to spaces | Allow to translate tabs to spaces. Set to zero to use tabs. | |
| Extra highlight arguments | Additional standard argument passed to highlight. Arguments that contains a white space must be protected inside quotes. See man highlight to a list of valid arguments and plugins. Eg: --doc-title='title with space' | Yes |
| Custom CSS Style | If the render engine is set to HTML allow to define a custom CSS style to override/extend the color scheme. More info about highlight HTML output on this page. | Yes |
| Interactive preview | DEPRECATED and available only before macOS 12 Monterey. If the render engine is set to HTML enable the javascript interpreter inside the preview window. Set only if you use some highlight plugins that output javascript code. This option disable the possibility to move the Quick Look preview with click and drag inside the window and opening the file with a double click. | Yes |
| Data limit | Maximum amount of data to format, data beyond the limit is omitted. Specify 0 to not limit. This option is ignored when using a Language Server. | |
| Convert line ending | Allow to convert Windows (CRLF) and Mac Classic (CR) line ending to the Unix style (LN). This option is ignored when a preprocessor is set or when a Language Server is enabled. The line ending conversion is made my dos2unix. | Yes |
| VCS Support | If enabled, allow to highlight lines added/edited/removed from last commit. It can handle VCS based on git and mercurial. | Yes |
| Custom Quick Look size | Allow you to choose a custom size for the content area of the Quick Look window. Use with caution on macOS before version 12 Monterey. | |
| Show about info | If enabled, shows information about this application at the bottom of the preview page. | Yes |
| Debug | If enabled, a colorize.log and colorize.rtf|html file will be created on your Desktop folder with the log of last rendering. | Yes |
You can also override the global options for some formats on the Formats tab.
When customizing the settings for a specific format, these options will be available:
| Append highlight arguments | Arguments appended to the Extra highlight arguments. Arguments that contains a white space must be protected inside quotes. | Yes |
| Preprocessor | Set a program or a shell script to preprocess the source file before the formatting. The program must output to stdout the data to be passed to highlight. You must pass the name of the source file using the $targetHL placeholder. You can also use the placeholder $escaped_targetHL with the special chars escaped inside a double quotes. With the preprocessor you can handle file format not directly supported by highlight. This option is ignored when using a Language Server. The execution of the preprocessor is made inside the same env of the script that handle highlight. For example you can beautify a JSON file with this preprocessor: python3 -m json.tool $targetHL or python3 -m json.tool "$escaped_targetHL". When you use a preprocessor you will probably want to disable the support for version control. | Yes |
| Syntax | Set which language must be used to recognize the source file. If not set will be used the file name extension. | Yes |
Advanced users can customize the single format to use an external Language Server:
| Executable | Full path of the Language Server executable. | Yes |
| Delay | Server initialization delay in ms. | Yes |
| Syntax | Syntax which is understood by the server. | Yes |
| Hover | Execute hover requests. Require the HTML render engine. | Yes |
| Semantic | Retrieve semantic token types (the Language Server must implement the protocol 3.16). | Yes |
| Syntax Error | Retrieve syntax error information (assumes hover or semantic). | Yes |
| Options | Custom command line options to pass to the Language Server. | Yes |
When using an external Language Server the preprocessor and the data limit settings are ignored.
Some format have a preconfigured custom settings to handle the data (for example java compiled class file can be decompiled before render).
You can also enable the support of common VCS to highlight the added/edited/removed lines from last commit.
In the General settings you must enable the VCS support. Then you can customize the path of git and mercurial binary. The you can choose the colors used to mark the changed lines. On every format you can also customize the colors.
On RTF mode, the VCS plugin can be disabled if the syntax language defines more keyword groups than those defined in the theme.
The Application can preview plain files without an extension whose format is unknown.
Only files recognized by the system with one of the following UTIs can be handled:
Files with an extension or associated to a dynamic UTI will not be handled. Files that have a only one dot as the first character in their name (like .gitignore, .env, ...) are considered to have no extension.
Unknown files are analyzed with the system utility /usr/bin/file for recognize mime type and encoding. No preprocessor is applied before analyzing the file.
Files recognized as images are handled by displaying the content within a web page (even if the rendering engine set in the settings is RTF). To be displayed correctly, the image format must be supported by WebKit.
On macOS 12 Monterey images and even, audio, movies and PDF files are displayed with the native Quick Look interface.
For other binary files it is possible to display a hex dump.
For text files, syntax highlighting is tried.
You can specify a criteria for the file name and the mime type to apply a syntax highlighting and/or a specific display format. The criteria are evaluated in the order in which they are set.
If no display format is set, the system will try to derive it starting from the mime type.
Note that some files with no extension can be recognized by macOS with a UTI if they have the com.apple.FinderInfo extended attributed set.
The Application has a GUI to customize the color schemes.
Standard schemas provided by highlight cannot be edited but can be duplicated and then customized.
For every tokens of a color scheme you can also set a custom inline CSS style. Some basic CSS style can be handled also by the RTF engine, but for a best view you must choose the HTML render engine. For this reason the preview of the Color Scheme always uses the HTML engine.
Please note that the inline CSS style is not put inside the HTML style attribute but embedded on the global <style> tag inside the class style definition of the token. So you can define a custom CSS style sheet that override the inline settings.
When inserting the style of a theme token it is possible to indicate whether this should override the default values for color and font style. If you want to use the custom theme with the RTF rendering engine it is required not to override the standard values.
Color schemes that uses inline CSS style are highlighted by an icon.
With the advanced settings enabled you can also customize the appearance of the Language Server Protocol tokens.
With the Inquiry window you can see if a specific file type is handled by the Quick Look Extension and also if it is supported by highlight.
Alternatively you can see the UTI of a file with this Terminal command:
It's likely that I didn't associate all the possible extensions managed by highlight. If you found an unhandled format please send me the output of above command.
Only the formats supported by highlight can be managed by this application.
A syntax_highlight_cli command line interface (CLI) is available to perform batch conversion.
The tool is located inside the Syntax Highlight.app/Contents/Resources folder (and should not be moved outside).
From the Application menu you can create a symbolic link into /usr/local/bin folder.
The CLI interface uses the same settings as the Quick Look extension, but you can override it if you wish.
The highlighted data is printed to the stdout or writed to file if you use the -o option.
** You cannot manually add support for a new file format.** This operation must be done during compilation time. Any attempt to manipulate the application causes the code signature to be violated, making it unusable!
See also the FAQ.
The problem may be due to several causes:
If the problem affects all file formats it must related to points 1. and 2., so try one or more of these action:
If the problem affects only a specific format it is possible that this was registered by some application with a non-standard UTI. Check the UTI with the Inquiry window and send me the value. The support for each format must be defined at compile time.
Also remember that some common files cannot be handled by third party extension because are reserved by the system (for example, .ts, .html, …).
No, Apple does not allow this functionality.
This is a deliberate choice. Most users want to see the formatted output and not the source code of their markdown files. If you need to view the markdown files (also with the possibility of choosing whether to show the formatting or the source code) I have developed QLMarkdown.
It depends… first the format must be handled by highlight. Check in the Inquiry window if the file is supported. If is supported please send me the UTI associated to the file. You can also view the UTI with this terminal command:
mdls -name kMDItemContentType -name kMDItemContentTypeTree filename.ext
Some common files cannot be handled by third party extension because are reserved by the system (for example, .ts, .html, …).
You can customize the behavior for files with no extension yourself. See Plain files settings.
This Application only generate the Quick Look Preview and does not provide a thumbnail service for the Finder icon.
When the Debug option is enabled (on the advanced settings) on your Desktop folder will be created two files for the last preview action:
Starting from macOS 10.15.0 Catalina the qlgenerator APIs are deprecated.
This project consists of these components:
MacOS 10.15 Catalina require sandboxed extension that prevent the execution of external processes (like shell script). To work around this problem, it is possible to use an XPC service that may have different security policies than the application / extension that invokes it. In this case the XPC service is not sandboxed.
The XPC service is executed automatically when requested by the application or the Quick Look Extension. After closing the Quick Look preview the process is automatically closed after some seconds releasing the resources.
The Application and the Quick Look Extension can preview files showing the formatted code as HTML, inside a WKWebView, or as RTF inside a NSTextView. Especially in Big Sur, the use of WebKit within the Quick Look Preview has numerous bugs, so before macOS 12 Monterey, the suggested rendering engine is RTF. From macOS 12 Monterey, the plugin adopt the new data based Quick Look API.
The settings are stored in ~/Library/Preferences/org.sbarex.SourceCodeSyntaxHighlight.plist. Custom themes and styles are saved in ~/Library/Application Support/Syntax Highlight.
The application embed the Highlight engine that is build inside the Xcode project.
Ok, so according to the source I references above, I would do the following:
List all registered UTIs:
List all registered Quick Look plugins:
İnfo about a plugin:
https://eclecticlight.co/2024/11/02/a-brief-history-of-icons-thumbnails-and-quicklook/
https://eclecticlight.co/2024/10/31/how-sequoia-has-changed-quicklook-and-its-thumbnails/
https://mjtsai.com/blog/2024/11/05/sequoia-no-longer-supports-quicklook-generator-plug-ins/
https://eclecticlight.co/2025/10/25/explainer-how-does-macos-recognise-file-types/
Developed by sbarex with ❤️.
Highlight is developed by Andre Simon.
Dos2unix is developed by Erwin Waterlander.
This application was inspired by anthonygelibert/QLColorCode and NSGod/qlstephen.
If you find this application useful, buy me a coffee.