skillfed

envtpl

Render jinja2 templates on the command line using shell environment variables

envtpl v0.8.0 124.9K downloads/30d#11,846 on PyPI244
Copyleft license GPL v3 Active released

What it is and what it does

envtpl is a command-line tool that processes Jinja2 templates by injecting shell environment variables into them. It reads a template file (typically with a .tpl extension), substitutes variables using Jinja2 syntax, and writes the rendered output to a file or stdout. The tool supports default values, conditional blocks, and a special environment() function to match variables by prefix—all standard Jinja2 features accessible from the shell.

The primary use case is Docker container initialization, where configuration files need to be generated at runtime with values from the container environment. By default, envtpl deletes the input template after rendering (though this can be disabled with --keep-template). It handles missing variables by throwing an error unless --allow-missing is passed, which substitutes empty strings instead.

Use it for:

  • Generate Docker container configuration files at startup by substituting environment variables into template files.
  • Create deployment-specific config files (nginx, Redis, etc.) from a single template with environment-driven values.
  • Build shell scripts or application configs that vary by environment (dev, staging, prod) without duplicating files.
  • Conditionally include or exclude configuration sections based on whether specific environment variables are defined.
  • Batch-process multiple template files in a CI/CD pipeline to inject build metadata or secrets.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Renders Jinja2 templates on the command line, substituting shell environment variables into template files with optional defaults and conditional logic.

Yes, if you need lightweight, shell-native template rendering for configuration files in Docker or deployment contexts. The single dependency, active maintenance, and lack of known vulnerabilities make it low-risk. The GPL v3 license requires review if you plan to redistribute or embed it in proprietary software; for internal use it is unproblematic. Not necessary if your deployment tool (Helm, Terraform, etc.) already handles templating.

Install

envtpl on PyPI

pip

pip install envtpl

uv

uv add envtpl

poetry

poetry add envtpl

Installing envtpl

Before you install

Installs cleanly with a single runtime dependency (Jinja2) and no compiled components. Active maintenance with recent commits; last release 148 days ago.

License in practice

Licensed under GPL v3 (copyleft). Any derivative work or bundled distribution must also be GPL v3; suitable for internal tools and open-source projects but requires careful review in proprietary contexts.

Quickstart

pip install envtpl

# Create template file (config.conf.tpl):
# foo = {{ FOO }}
# bar = "{{ BAR | default("default_value") }}"

# Render from command line:
# FOO=123 BAR=abc envtpl config.conf.tpl
# Output: config.conf with variables substituted

Requires Python 3.10 or later; environment variables must be set in the shell before invocation.

Verify before relying

  • Whether the package handles special characters or escaping in environment variable values reliably.
  • Performance characteristics when processing very large template files or many environment variables.

Package facts

License GPL v3 (copyleft)
Python support supports the current Python release (>=3.10)
Install friction low — pure-Python wheel
Runtime dependencies 1 — Jinja2
Maintenance actively maintained — 148 days since the last release
Last repo commit
First released
Downloads 124,923/month — #11,846 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: envtpl-0.8.0-py3-none-any.whl

Keywords: template, environment, variables, parameter, substitution, shell, jinja2, docker

License :: OSI Approved :: GNU General Public License v3 (GPLv3)Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14

Tags

jinja2 template rendering clienvironment variable template substitutiondocker config file templatingshell variable template enginecommand line template processorjinja2 environment variablesconfig file templating tool
docker-configcli-tooltemplate-engine

More Utilities packages