#jinja #jinja2 #templates


a powerful template engine for Rust with minimal dependencies

37 releases (breaking)

new 0.30.2 Jan 28, 2023
0.29.0 Jan 14, 2023
0.27.0 Dec 11, 2022
0.26.0 Nov 11, 2022
0.8.2 Nov 8, 2021

#4 in Template engine

Download history 3705/week @ 2022-10-15 5020/week @ 2022-10-22 6633/week @ 2022-10-29 6046/week @ 2022-11-05 5145/week @ 2022-11-12 5387/week @ 2022-11-19 5152/week @ 2022-11-26 5587/week @ 2022-12-03 6547/week @ 2022-12-10 4105/week @ 2022-12-17 2552/week @ 2022-12-24 4331/week @ 2022-12-31 5128/week @ 2023-01-07 4479/week @ 2023-01-14 4482/week @ 2023-01-21 7252/week @ 2023-01-28

22,412 downloads per month
Used in 33 crates (16 directly)


10K SLoC

MiniJinja: a powerful template engine for Rust with minimal dependencies

Build Status License Crates.io rustc 1.61.0 Documentation

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

It's implemented on top of serde 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 v0.30.2 (minijinja)
    └── serde v1.0.144

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


Example Template

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


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());

Minimum Rust Version

MiniJinja's development version requires Rust 1.61 due to limitations with HRTBs in older Rust versions.

MiniJinja 0.20 supports Rust versions down to 1.45. It is possible to write code that is compatible with both 0.20 and newer versions of MiniJinja which should make it possible to defer the upgrade to later.

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.
  • TinyTemplate: minimal footprint template engine with syntax that takes lose inspiration from Jinja and handlebars.
  • Liquid: an implementation of Liquid templates for Rust. Liquid was inspired by Django from which Jinja took it's inspiration.


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


~12K SLoC