envtpl
Render jinja2 templates on the command line using shell environment variables
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 envtpluv
uv add envtplpoetry
poetry add envtplInstalling 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
Tags
More Utilities packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
charset-normalizerDetects and normalizes text encoding from…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
PygmentsPygments is a syntax highlighter that colorizes…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
j2clij2cli is a command-line tool that renders…
permissive · top 5,000 on PyPI
jinja2-cliA command-line interface for Jinja2 templating…
permissive · top 5,000 on PyPI
ruamel.yaml.jinja2Enables Jinja2 templating within YAML files by…
permissive · top 5,000 on PyPI
django-jinjaIntegrates Jinja2 templating into Django,…
permissive · top 15,000 on PyPI
Jinja2Jinja2 is a templating engine that renders…
permissive · top 100 on PyPI
dump-envGenerates .env files by merging an…
permissive · top 15,000 on PyPI
aiohttp-jinja2Integrates Jinja2 template rendering into…
permissive · top 5,000 on PyPI
jinjanatorA command-line tool that renders Jinja2…
permissive · top 5,000 on PyPI
jinja-cliA command-line tool that renders Jinja2…
copyleft · top 15,000 on PyPI
git-changelogGenerates changelogs automatically from git…
permissive · top 15,000 on PyPI