mitsuhiko
minijinja
Rust

MiniJinja is a powerful but minimal dependency template engine for Rust compatible with Jinja/Jinja2

Last updated Jul 8, 2026
2.7k
Stars
156
Forks
32
Issues
+9
Stars/day
Attention Score
88
Language breakdown
No language data available.
โ–ธ Files click to expand
README

MiniJinja: a powerful template engine with minimal dependencies

License Crates.io rustc 1.63.0 Documentation

MiniJinja is a powerful but minimal dependency template engine which is based on the syntax and behavior of the Jinja2 template engine for Python.

It's implemented in Rust and Go and is also available via WASM for JavaScript and as a Python extension module and as a command line utility.

It's supports all serde types and only has it as a single required dependency. It supports a range of features from Jinja2 including inheritance, filters and more. The goal is that it should be possible to use some templates in Rust programs without the fear of pulling in complex dependencies for a small problem. Additionally it tries not to re-invent something but stay in line with prior art to leverage an already existing ecosystem of editor integrations.

$ cargo tree
minimal v0.1.0 (examples/minimal)
โ””โ”€โ”€ minijinja v2.21.0 (minijinja)
    โ””โ”€โ”€ serde v1.0.144

Additionally minijinja is also available as an (optionally pre-compiled) command line executable called minijinja-cli:

$ curl -sSfL https://github.com/mitsuhiko/minijinja/releases/latest/download/minijinja-cli-installer.sh | sh
$ echo "Hello {{ name }}" | minijinja-cli - -Dname=World
Hello World

You can play with MiniJinja online in the browser playground powered by a WASM build of MiniJinja.

Goals:

allows the use as a DSL Python, and C

Example

Example Template:

{% extends "layout.html" %}
{% block body %}
  <p>Hello {{ name }}!</p>
{% endblock %}

Invoking from Rust:

use minijinja::{Environment, context};

fn main() { let mut env = Environment::new(); env.add_template("hello.txt", "Hello {{ name }}!").unwrap(); let template = env.get_template("hello.txt").unwrap(); println!("{}", template.render(context! { name => "World" }).unwrap()); }

Getting Help

If you are stuck with MiniJinja, have suggestions or need help, you can use the GitHub Discussions.

Related Crates

auto reloading functionality of environments utilities for embedding templates in a binary additional utilities too specific for the core available to Python available to JavaScript via WASM (for Node and Browser) implementation of MiniJinja

Use Cases and Users

Here are some interesting Open Source users and use cases of MiniJinja. The examples link directly to where the engine is used so you can see how it's utilized:

  • AI Chat Templating:
* HuggingFace uses it to render LLM chat templates * mistral.rs uses it to render LLM chat templates * BoundaryML's BAML uses it to render LLM chat templates * LSP-AI uses it to render LLM chat templates * LoRAX uses it to render LLM chat templates * tensorzero uses it to render LLM and system templates
  • Data and Processing:
* Cube uses it for data modelling * PRQL uses it to handle DBT style pipelines * qsv uses it to render templates from CSV files, to construct payloads to post to web services and to infer Data Dictionaries, Descriptions & Tags or Chat with your data.
  • HTML Generation:
* Zine uses it to generate static HTML * Oranda uses it to generate HTML landing pages
  • Code Generation:
* OpenTelemetry's Weaver uses it to generate documentation, code and other outputs from the OTel specification. * Maturin uses it to generate project structures * cargo-dist uses it to generate CI and project configuration

Similar Projects

These are related template engines for Rust:

  • Askama: Jinja inspired, type-safe, requires template
precompilation. Has significant divergence from Jinja syntax in parts.
  • Tera: Jinja inspired, dynamic, has divergences from Jinja.
  • Liquid: an implementation of Liquid templates for Rust.
Liquid was inspired by Django from which Jinja took its inspiration. with syntax that takes lose inspiration from Jinja and handlebars.

Sponsor

If you like the project and find it useful you can become a sponsor.

AI Use Disclaimer

This codebase mostly predates LLM based code generation but some recent features have been built with support of AI. For the AI contribution rules see AI Disclosure Rules.

License and Links

๐Ÿ”— More in this category

ยฉ 2026 GitRepoTrend ยท mitsuhiko/minijinja ยท Updated daily from GitHub