{"id":13477893,"url":"https://github.com/mitsuhiko/minijinja","last_synced_at":"2026-04-02T22:06:47.576Z","repository":{"id":37093240,"uuid":"406663386","full_name":"mitsuhiko/minijinja","owner":"mitsuhiko","description":"MiniJinja is a powerful but minimal dependency template engine for Rust compatible with Jinja/Jinja2","archived":false,"fork":false,"pushed_at":"2025-05-06T10:18:13.000Z","size":4139,"stargazers_count":2014,"open_issues_count":21,"forks_count":114,"subscribers_count":12,"default_branch":"main","last_synced_at":"2025-05-08T20:55:46.812Z","etag":null,"topics":["jinja","jinja2","rust","templates"],"latest_commit_sha":null,"homepage":"https://docs.rs/minijinja","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mitsuhiko.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":["mitsuhiko"]}},"created_at":"2021-09-15T07:51:31.000Z","updated_at":"2025-05-08T20:42:16.000Z","dependencies_parsed_at":"2023-11-20T00:25:06.662Z","dependency_job_id":"90327d6e-d2cf-49b3-a620-0e379a161bb4","html_url":"https://github.com/mitsuhiko/minijinja","commit_stats":{"total_commits":643,"total_committers":18,"mean_commits":35.72222222222222,"dds":0.0528771384136858,"last_synced_commit":"480c61ded15219aee21f4cec64adfdec76add7aa"},"previous_names":[],"tags_count":95,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitsuhiko%2Fminijinja","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitsuhiko%2Fminijinja/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitsuhiko%2Fminijinja/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitsuhiko%2Fminijinja/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mitsuhiko","download_url":"https://codeload.github.com/mitsuhiko/minijinja/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253156799,"owners_count":21863007,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["jinja","jinja2","rust","templates"],"created_at":"2024-07-31T16:01:49.257Z","updated_at":"2026-04-02T22:06:47.566Z","avatar_url":"https://github.com/mitsuhiko.png","language":"Rust","funding_links":["https://github.com/sponsors/mitsuhiko"],"categories":["Rust"],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"https://github.com/mitsuhiko/minijinja/raw/main/artwork/logo.png\" alt=\"\" width=320\u003e\n  \u003cp\u003e\u003cstrong\u003eMiniJinja: a powerful template engine with minimal dependencies\u003c/strong\u003e\u003c/p\u003e\n\n[![License](https://img.shields.io/github/license/mitsuhiko/minijinja)](https://github.com/mitsuhiko/minijinja/blob/main/LICENSE)\n[![Crates.io](https://img.shields.io/crates/d/minijinja.svg)](https://crates.io/crates/minijinja)\n[![rustc 1.63.0](https://img.shields.io/badge/rust-1.63%2B-orange.svg)](https://img.shields.io/badge/rust-1.63%2B-orange.svg)\n[![Documentation](https://docs.rs/minijinja/badge.svg)](https://docs.rs/minijinja)\n\n\u003c/div\u003e\n\nMiniJinja is a powerful but minimal dependency template engine\nwhich is based on the syntax and behavior of the\n[Jinja2](https://jinja.palletsprojects.com/) template engine for Python.\n\nIt's implemented in [Rust](https://github.com/mitsuhiko/minijinja/tree/main/minijinja) and [Go](https://github.com/mitsuhiko/minijinja/tree/main/minijinja-go) and is also available via WASM for [JavaScript](https://github.com/mitsuhiko/minijinja/tree/main/minijinja-js)\nand as a [Python extension module](https://github.com/mitsuhiko/minijinja/tree/main/minijinja-py) and as a [command line utility](https://github.com/mitsuhiko/minijinja/tree/main/minijinja-cli).\n\nIt's supports all `serde` types and only has it as a single required\ndependency. It supports [a range of features from Jinja2](https://github.com/mitsuhiko/minijinja/blob/main/COMPATIBILITY.md)\nincluding inheritance, filters and more.  The goal is that it should be possible\nto use some templates in Rust programs without the fear of pulling in complex\ndependencies for a small problem.  Additionally it tries not to re-invent\nsomething but stay in line with prior art to leverage an already existing\necosystem of editor integrations.\n\n```\n$ cargo tree\nminimal v0.1.0 (examples/minimal)\n└── minijinja v2.19.0 (minijinja)\n    └── serde v1.0.144\n```\n\nAdditionally minijinja is also available as an (optionally pre-compiled) command line executable\ncalled [`minijinja-cli`](https://github.com/mitsuhiko/minijinja/tree/main/minijinja-cli):\n\n```\n$ curl -sSfL https://github.com/mitsuhiko/minijinja/releases/latest/download/minijinja-cli-installer.sh | sh\n$ echo \"Hello {{ name }}\" | minijinja-cli - -Dname=World\nHello World\n```\n\nYou can play with MiniJinja online [in the browser playground](https://mitsuhiko.github.io/minijinja-playground/)\npowered by a WASM build of MiniJinja.\n\n**Goals:**\n\n* [Well documented](https://docs.rs/minijinja), compact API\n* Minimal dependencies, reasonable compile times and [decent runtime performance](https://github.com/mitsuhiko/minijinja/tree/main/benchmarks#comparison-results)\n* [Stay as close as possible](https://github.com/mitsuhiko/minijinja/blob/main/COMPATIBILITY.md) to Jinja2\n* Support for [expression evaluation](https://docs.rs/minijinja/latest/minijinja/struct.Expression.html) which\n  allows the use [as a DSL](https://github.com/mitsuhiko/minijinja/tree/main/examples/dsl)\n* Support for all [`serde`](https://serde.rs) compatible types\n* [Well tested](https://github.com/mitsuhiko/minijinja/tree/main/minijinja/tests)\n* Support for [dynamic runtime objects](https://docs.rs/minijinja/latest/minijinja/value/trait.Object.html) with methods and dynamic attributes\n* [Descriptive errors](https://github.com/mitsuhiko/minijinja/tree/main/examples/error)\n* Bindings for [JavaScript](https://github.com/mitsuhiko/minijinja/tree/main/minijinja-js),\n  [Python](https://github.com/mitsuhiko/minijinja/tree/main/minijinja-py), and [C](https://github.com/mitsuhiko/minijinja/tree/main/minijinja-cabi)\n* Also available for [Go](https://github.com/mitsuhiko/minijinja/tree/main/minijinja-go)\n* Comes with a handy [CLI](https://github.com/mitsuhiko/minijinja/tree/main/minijinja-cli)\n* [Compiles to WebAssembly](https://github.com/mitsuhiko/minijinja-playground/blob/main/src/lib.rs)\n\n## Example\n\n**Example Template:**\n\n```jinja\n{% extends \"layout.html\" %}\n{% block body %}\n  \u003cp\u003eHello {{ name }}!\u003c/p\u003e\n{% endblock %}\n```\n\n**Invoking from Rust:**\n\n```rust\nuse minijinja::{Environment, context};\n\nfn main() {\n    let mut env = Environment::new();\n    env.add_template(\"hello.txt\", \"Hello {{ name }}!\").unwrap();\n    let template = env.get_template(\"hello.txt\").unwrap();\n    println!(\"{}\", template.render(context! { name =\u003e \"World\" }).unwrap());\n}\n```\n\n## Getting Help\n\nIf you are stuck with `MiniJinja`, have suggestions or need help, you can use the\n[GitHub Discussions](https://github.com/mitsuhiko/minijinja/discussions).\n\n## Related Crates\n\n* [minijinja-autoreload](https://github.com/mitsuhiko/minijinja/tree/main/minijinja-autoreload): provides\n  auto reloading functionality of environments\n* [minijinja-embed](https://github.com/mitsuhiko/minijinja/tree/main/minijinja-embed): provides\n  utilities for embedding templates in a binary\n* [minijinja-contrib](https://github.com/mitsuhiko/minijinja/tree/main/minijinja-contrib): provides\n  additional utilities too specific for the core\n* [minijinja-py](https://github.com/mitsuhiko/minijinja/tree/main/minijinja-py): makes MiniJinja\n  available to Python\n* [minijinja-js](https://github.com/mitsuhiko/minijinja/tree/main/minijinja-js): makes MiniJinja\n  available to JavaScript via WASM (for Node and Browser)\n* [minijinja-go](https://github.com/mitsuhiko/minijinja/tree/main/minijinja-go): a native Go\n  implementation of MiniJinja\n* [minijinja-cli](https://github.com/mitsuhiko/minijinja/tree/main/minijinja-cli): a command line utility.\n* [minijinja-cabi](https://github.com/mitsuhiko/minijinja/tree/main/minijinja-cabi): a C binding to MiniJinja.\n\n## Use Cases and Users\n\nHere are some interesting Open Source users and use cases of MiniJinja.  The examples link directly to where\nthe engine is used so you can see how it's utilized:\n\n* AI Chat Templating:\n  * **[HuggingFace](https://huggingface.co/docs/text-generation-inference/index)** uses it to [render LLM chat templates](https://github.com/huggingface/text-generation-inference/blob/0759ec495e15a865d2a59befc2b796b5acc09b50/router/src/infer/mod.rs)\n  * **[mistral.rs](https://github.com/EricLBuehler/mistral.rs)** uses it to [render LLM chat templates](https://github.com/EricLBuehler/mistral.rs/blob/c834f59fe0b3b020a56cb6a0279a051370554539/mistralrs-core/src/pipeline/chat_template.rs)\n  * **[BoundaryML's BAML](https://docs.boundaryml.com/)** uses it to [render LLM chat templates](https://github.com/BoundaryML/baml/blob/17123de7ea653f51547576169bb0589d39053edc/engine/baml-lib/jinja/src/lib.rs)\n  * **[LSP-AI](https://github.com/SilasMarvin/lsp-ai)** uses it to [render LLM chat templates](https://github.com/SilasMarvin/lsp-ai/blob/1f70756c5b48e9098d64a7c5ce63ac803bc5d0ab/crates/lsp-ai/src/template.rs)\n  * **[LoRAX](https://loraexchange.ai/)** uses it to [render LLM chat templates](https://github.com/predibase/lorax/blob/6a83954b8c6ffd51eb69e7096ee2730d53b903dd/router/src/infer.rs)\n  * **[tensorzero](https://www.tensorzero.com/)** uses it to [render LLM and system templates](https://github.com/tensorzero/tensorzero/blob/26ae697f219c1f0385fe7936b9f04b97ff318f61/tensorzero-internal/src/minijinja_util.rs#L2)\n\n* Data and Processing:\n  * **[Cube](https://cube.dev/docs/product/data-modeling/dynamic/jinja)** uses it [for data modelling](https://github.com/cube-js/cube/tree/db11c121c77c663845242366d3d972b9bc30ae54/packages/cubejs-backend-native/src/template/mj_value)\n  * **[PRQL](https://prql-lang.org/)** uses it [to handle DBT style pipelines](https://github.com/PRQL/prql/blob/59fb3cc4b9b6c9e195c928b1ba1134e2c5706ea3/prqlc/prqlc/src/cli/jinja.rs#L21)\n  * **[qsv](https://qsv.dathere.com)** uses it [to render templates from CSV files](https://github.com/jqnatividad/qsv/blob/master/src/cmd/template.rs#L2), to [construct payloads to post to web services](https://github.com/jqnatividad/qsv/blob/master/src/cmd/fetchpost.rs#L3) and to [infer Data Dictionaries, Descriptions \u0026 Tags or Chat with your data](https://github.com/dathere/qsv/blob/master/src/cmd/describegpt.rs#L2).\n\n* HTML Generation:\n  * **[Zine](https://github.com/zineland/zine)** uses it to [generate static HTML](https://github.com/zineland/zine/blob/17285efe9f9a63b79a42a738b54d4d730b8cd551/src/engine.rs#L8)\n  * **[Oranda](https://github.com/axodotdev/oranda)** uses it to [generate HTML landing pages](https://github.com/axodotdev/oranda/blob/fb97859c99ab81f644ab5b1449f725fc5c3e9721/src/site/templates.rs)\n\n* Code Generation:\n  * **[OpenTelemetry's Weaver](https://github.com/open-telemetry/weaver)** uses it to [generate documentation, code and other outputs](https://github.com/open-telemetry/weaver/blob/d49881445e09beb42e1a394bfa5f3068c660daf3/crates/weaver_forge/src/lib.rs#L482-L567) from the OTel specification.\n  * **[Maturin](https://github.com/PyO3/maturin)** uses it to [generate project structures](https://github.com/PyO3/maturin/blob/e35097e6cf3b9115736e8ae208972178029a20d0/src/new_project.rs)\n  * **[cargo-dist](https://github.com/axodotdev/cargo-dist)** uses it to [generate CI and project configuration](https://github.com/axodotdev/cargo-dist/blob/4cd61134863f54ca5a037400ebec71d039d42742/cargo-dist/src/backend/templates.rs)\n\n## Similar Projects\n\nThese are related template engines for Rust:\n\n* [Askama](https://crates.io/crates/askama): Jinja inspired, type-safe, requires template\n  precompilation. Has significant divergence from Jinja syntax in parts.\n* [Tera](https://crates.io/crates/tera): Jinja inspired, dynamic, has divergences from Jinja.\n* [Liquid](https://crates.io/crates/liquid): an implementation of Liquid templates for Rust.\n  Liquid was inspired by Django from which Jinja took its inspiration.\n* [TinyTemplate](https://crates.io/crates/tinytemplate): minimal footprint template engine\n  with syntax that takes lose inspiration from Jinja and handlebars.\n\n## Sponsor\n\nIf you like the project and find it useful you can [become a\nsponsor](https://github.com/sponsors/mitsuhiko).\n\n## AI Use Disclaimer\n\nThis codebase mostly predates LLM based code generation but some recent features\nhave been built with support of AI.  For the AI contribution rules see\n[AI Disclosure Rules](CONTRIBUTING.md#ai-disclosure).\n\n## License and Links\n\n- [Documentation](https://docs.rs/minijinja/)\n- [Discussions](https://github.com/mitsuhiko/minijinja/discussions)\n- [Examples](https://github.com/mitsuhiko/minijinja/tree/main/examples)\n- [Issue Tracker](https://github.com/mitsuhiko/minijinja/issues)\n- [MiniJinja Playground](https://mitsuhiko.github.io/minijinja-playground/)\n- [Updating Guide](UPDATING.md)\n- License: [Apache-2.0](https://github.com/mitsuhiko/minijinja/blob/main/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmitsuhiko%2Fminijinja","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmitsuhiko%2Fminijinja","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmitsuhiko%2Fminijinja/lists"}