Skip to content

Repository files navigation

Silicate

Python bindings for Silicon's renderer.
Create beautiful images of your source code, powered by Rust.

Sponsor

PyPILicenseStars

Silicate example: Python code rendered with the Dracula theme


Get Started

uv add silicate
importsilicatepng_bytes=silicate.generate(
"print('Hello, World!')",
language="python",
theme="Dracula",
)

What is Silicate?

Silicate is a Python binding for Silicon, the Rust tool that turns source code into beautifully rendered PNGs. Unlike wrapper approaches that shell out to a CLI, Silicate uses PyO3 to call Silicon's Rust library directly, giving you native performance with a clean Python API.

Features

  • Native performance — no subprocess, no temp files; the renderer runs in-process via PyO3.
  • 24+ built-in themes — Dracula, Nord, Monokai, GitHub, Solarized, and more.
  • Full Silicon control — every renderer option exposed as a keyword argument.
  • PNG bytes or filegenerate() returns bytes, to_file() writes directly.

Usage

importsilicate# PNG bytespng_bytes=silicate.generate(
"print('Hello, World!')",
language="python",
theme="Dracula",
)
# Save directly to filesilicate.to_file(
"fn main() { println!(\"Hello!\"); }",
"output.png",
language="rs",
theme="Nord",
window_title="main.rs",
)
# Explore available themes and languagesprint(silicate.list_themes())
print(silicate.list_languages())

Theme gallery

Dracula
Nord
Monokai Extended
GitHub
Solarized Dark
Your code here

Options

All parameters after code (and output for to_file) are keyword-only:

ParameterDefaultDescription
language"python"Syntax highlighting language
theme"Dracula"Color theme (use list_themes())
fontNoneFont list as [("Name", size)], defaults to Hack 26pt
show_line_numbersTrueDisplay line numbers
show_window_controlsTruemacOS-style window buttons
window_titleNoneTitle bar text
round_cornerTrueRounded image corners
background"#abb8c3"Background color (hex)
shadow_color"#707070"Shadow color (hex)
shadow_blur_radius50.0Shadow blur radius
pad_horiz80Horizontal padding (px)
pad_vert100Vertical padding (px)
shadow_offset_x0Shadow offset in X axis
shadow_offset_y0Shadow offset in Y axis
code_pad_right25Right padding inside code window (px)
highlight_linesNone1-based line numbers to highlight
tab_width4Spaces per tab
line_offset1Starting line number
line_pad2Line spacing (px)

Development

# Clone with submodules
git clone --recurse-submodules https://github.com/alltuner/silicate.git
cd silicate
# Create venv and build
uv venv
VIRTUAL_ENV=.venv uvx maturin develop
# Test
uv run python -c "import silicate; print(silicate.list_themes())"

License

MIT

Support the project

Silicate is an open source project built by David Poblador i Garcia through All Tuner Labs.

If this project was useful to you, consider supporting its development.


Built by David Poblador i Garcia with the support of All Tuner Labs.
Made with ❤️ in Poblenou, Barcelona.

About

Python bindings for Silicon's renderer

Resources

Code of conduct

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Sponsor this project

Contributors

Languages