hylite is a CLI tool for turning source code into HTML using highlight.js.

It's best explained with a quick demo:


> hylite --version
1.0.7
> echo '{"foo": true}' | hylite -l json
<span class="hljs-punctuation">{</span><span class="hljs-attr">&quot;foo&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-literal"><span class="hljs-keyword">true</span></span><span class="hljs-punctuation">}</span>

I.e. you feed the CLI some source and a language. If you give it a file, it figures out the language by the file extension. For example:


> hylite test.yml
<span class="hljs-attr">foo:</span>
  <span class="hljs-bullet">-</span> <span class="hljs-string">bar</span>

Anyway, the project has been around for some time. It's written in Bun and as of version 1.0.7, from now every release is uploaded to GitHub as release asset files. You can see them on: https://github.com/peterbe/hylite

Each file is an executable for different hardware and operating systems.

Here's an example of how I use it for this very blog's admin tool that converts code snippets in within Markdown. (The Markdown-to-HTML is written in Python, but code snippets are subprocess piped to hylite because none of the Python Markdown syntax highlighters were good enough. Especially with JSX)


#!/bin/bash

set -e

wget -O /tmp/hylite-linux-x64 https://github.com/peterbe/hylite/releases/latest/download/hylite-linux-x64
chmod +x /tmp/hylite-linux-x64
echo "Version of recent download:"
/tmp/hylite-linux-x64 --version
mv /tmp/hylite-linux-x64 ~/bin
cd ~/bin
rm -f hylite
ln -s hylite-linux-x64 hylite

echo "Version of installed hylite:"
hylite --version

Essentially, it downloads the latest hylite-linux-x64 for this server and moves it into that $PATH under the name hylite. Now, you get a super fast code-to-HTML converter as a single executable. No need for npx or node_modules or even bun.

Bonus speed test

By the way, it's fast.
The command:


hylite test.yml

takes on average 32 milliseconds to fully run.

And because the project is written in regular TypeScript, it builds a dist/index.js file. So you can equally run node dist/index.js test.yml or bun run dist/index.js test.yml. Those take 62 milliseconds and 44 milliseconds respectively.

Comments

Your email will never ever be published.

Previous:
In Python, you have to specify the type and not rely on inference October 10, 2025 Python, TypeScript
Related by category:
Always run biome migrate after upgrading biome August 16, 2025 Bun
Video to Screenshots app June 21, 2025 Bun
Parse a CSV file with Bun September 13, 2023 Bun
How I end-to-end test my Bun CLI app September 18, 2025 Bun
Related by keyword:
Trying out the new Bun "Compile to bytecode" October 15, 2024 JavaScript, Bun
Introducing hylite - a Node code-syntax-to-HTML highlighter written in Bun October 3, 2023 Node, JavaScript, Bun
The importance of env (and how it works with virtualenv) September 18, 2008 Python
ztar - my wrapper on tar -z June 29, 2005 Python, Linux