Skip to content

DuckDB Extension

Tera

Render Tera templates from DuckDB SQL using JSON context. Generate text or HTML with variables, loops, and filters, or load templates from files.

48,754
extension loads · last 90 days
On this page

Render a template for each query row

Tera is a template language inspired by Jinja2. It uses placeholders, conditions, loops, and filters to combine a template with structured input. The DuckDB extension takes JSON context and returns the rendered text.

Use it to generate configuration files, messages, or HTML from query results, particularly when you already maintain Tera templates. SQL selects and prepares the data; the template specifies the output format. Set HTML escaping according to where the rendered string will be used.

Example

Render a greeting

Pass a JSON object as the template context. Its name field fills the template variable.

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

INSTALL tera FROM community;
LOAD tera;

SELECT tera_render('Hello {{ name }}!', '{"name":"Mina"}') AS greeting;

Expected result

greeting
Hello Mina!

Tera and MiniJinja have similar syntax but different engines and filter support. Test existing templates before switching between them.

Common tasks

Deep Dive

Technical Details

Reference

Extension Contents

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

Render
tera_render() Object type: Scalar function Render a Tera template, optionally with a JSON context.

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
48,754
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 6.30 MB
Linux aarch64 5.54 MB
macOS Apple Silicon 4.01 MB
Windows x86_64 11.38 MB
Windows x86_64 (MinGW) 20.72 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 .