Skip to content

DuckDB Extension

MiniJinja

Render Jinja-style templates from DuckDB SQL with MiniJinja. Pass JSON context to generate text, HTML, configuration, or SQL strings.

50,279
extension loads · last 90 days
On this page

Turn query results into formatted text

MiniJinja is a template engine using Jinja-style expressions, conditions, loops, and filters. This extension combines a template with JSON context inside DuckDB and returns the rendered text as a string.

Use it to generate a message, configuration fragment, or HTML snippet from each query row. Your SQL supplies the values and the template controls their presentation. Choose escaping appropriate to the output: HTML needs different treatment from plain text.

Example

Render a message from JSON context

The template inserts a name and loops through a short list. This example produces plain text.

Tested with DuckDB 1.5.6. Browser examples use Haybarn-Wasm 1.5.6.

INSTALL minijinja FROM community;
LOAD minijinja;

SELECT minijinja_render_with_context(
  'Hello {{ name }}! Items: {{ items | join(", ") }}',
  '{"name":"Mina","items":["tea","coffee"]}',
  autoescape := false
) AS message;

Expected result

message
Hello Mina! Items: tea, coffee

Use HTML autoescaping when rendering HTML. Disabling it here is appropriate for plain text; rendered SQL is still text until you explicitly execute it.

Common tasks

Deep Dive

Technical Details

Reference

Extension Contents

Quick reference to all available functions and settings organized by category.

Render
minijinja_render() Object type: Scalar function Render a MiniJinja template without a JSON context.
minijinja_render_with_context() Object type: Scalar function Render a MiniJinja template with a JSON context, including contexts built from columns with json_object.

API Reference

Function Reference

Practical Examples

Cookbook

Real-world recipes and patterns for common use cases.

Platform Support

Compatibility

Extension availability may vary by platform and DuckDB version. Check below to ensure this extension supports your environment before installation.

Quick Facts

Release status Stable
Software License MIT
Pricing Free
Written In Rust
Source Available Yes
View on GitHub
Usage
50,279
loads · last 90 days

Platforms

DuckDB 2.0.0

  • Linux x86_64 aarch64
  • Linux (musl) Not available
  • macOS Apple Silicon
  • Windows x86_64 x86_64 (MinGW)
  • WASM Not available
Compiled binary sizes
Platform Architecture Size
Linux x86_64 5.64 MB
Linux aarch64 4.94 MB
macOS Apple Silicon 3.50 MB
Windows x86_64 10.80 MB
Windows x86_64 (MinGW) 19.75 MB

Compressed download sizes for the release shown above.

DuckDB & Haybarn

Release calendar
  • DuckDB v2.0.0 Query.Farm repository Supported
  • Haybarn v1.5.6 Built-in community repository Supported

Browser examples use Haybarn-Wasm 1.5.6.

Checked .