Code has structure. Make it visible.

Tree-sitter syntax highlighting for Rust, JavaScript, and Python.

Turn source code into highlighted tokens, HTML, or terminal output.

MarkdownRust
# Hello, Comfit

```rust
fn main() {
    let name = "Comfit";

    println!("{:?}", [name]);
}
```

Start with the source.

A heading. A code block. A few lines of Rust. Comfit starts with the text you already have.

Markdown
# Hello, Comfit

```rust
fn main() {
    let name = "Comfit";

    println!("{:?}", [name]);
}
```

Find the language inside the language.

A Rust code block is still Rust, even inside Markdown.

Comfit follows embedded languages so each part gets its own highlighting.

MarkdownRust
# Hello, Comfit

```rust
fn main() {
    let name = "Comfit";

    println!("{:?}", [name]);
}
```

Give each token its role.

Keywords, strings, functions, and local references have different jobs.

Tree-sitter queries identify what to highlight. Comfit resolves overlapping captures and carries local-binding styles through their references.

Here, let is a keyword, "Comfit" is a string, and name is a local binding.

Markdown
# Hello, Comfit

```rust
fn main() {
    let name = "Comfit";

    println!("{:?}", [name]);
}
```

Choose how the code reads.

Keep the highlighting. Change the presentation.

Apply a theme, color nested brackets, or emphasize the lines you want readers to notice.

Markdown
# Hello, Comfit

```rust
fn main() {
    let name = "Comfit";

    println!("{:?}", [name]);
}
```

Put it where your code appears.

Render HTML for a website, ANSI for a terminal, or tokens for your own interface.

The shared highlighting engine is available through Rust, JavaScript, and Python integrations.

HTML previewMarkdown
# Hello, Comfit

```rust
fn main() {
    let name = "Comfit";

    println!("{:?}", [name]);
}
```

Get started in your environment.

Install Comfit and render a short Rust snippet as highlighted HTML from your own project.

Install
InstallShell
cargo add comfit --features rust,render-html
src/main.rsRust
fn main() -> Result<(), comfit::Error> {
    let mut highlighter = comfit::Highlighter::new()?;
    let result = highlighter.highlight("fn main() {}", "rust", &Default::default())?;
    println!("{}", result.render_html_classes(&Default::default()));
    Ok(())
}

The HTML uses classes you can style with CSS. Rust API reference

Use Comfit in your workflow.

Highlight code when you build a site, in the browser, or directly in a terminal.

Markdown with rehype

Add Comfit after remark-rehype and before rendering HTML in your unified pipeline.

JavaScript
pipeline.use(rehypeComfit, { theme: "catppuccin-mocha" });
Browser with WebAssembly

Initialize the runtime, load the Rust grammar, and highlight source in the browser.

JavaScript
const tokens = highlighter.highlight(source, "rust");
Terminal with the CLI

Use comfit-cli to print a source file with ANSI colors and line numbers.

Shell
comfit ansi main.rs --theme catppuccin-mocha --line-numbers

Bring your own theme.

Convert a local VS Code theme to Comfit’s TOML format, then use it to color the same Rust snippet in your terminal.

Convert and applyShell
comfit convert theme.json --name "Custom" -o custom.toml
printf 'fn main() {}\n' |
  comfit ansi --language rust --theme-file custom.toml

Try your own code.

Pick a language, paste a snippet, and see what Comfit highlights.

Open the playground