close
Skip to content

Cookiecutter

Cookiecutter is a project templating and scaffolding tool that generates new projects from Jinja2-based templates. It prompts for values, then renders file contents and paths to produce a ready-to-use project structure for Python and others.

Installation and Setup

Install it from PyPI:

Language: Windows PowerShell
(venv) PS> py -m pip install cookiecutter
Language: Shell
(venv) $ python -m pip install cookiecutter

A template defines prompts and defaults in cookiecutter.json:

Language: JSON Filename: cookiecutter.json
{
  "project_name": "example",
  "package_name": "example",
  "license": ["MIT", "Apache-2.0"]
}

Optional user configuration lives in ~/.cookiecutterrc and can set a default template directory and context.

Key Features

  • Provides Jinja2-powered scaffolding that renders file contents and paths, including directory names.
  • Works with templates from local directories, Git and Mercurial repositories, and ZIP archives.
  • Supports interactive prompts with defaults, plus unattended runs with --no-input.
  • Provides hooks (pre_prompt, pre_gen_project, post_gen_project) to validate inputs and customize output.
  • Allows for repeatable runs via replay files with --replay, --replay-file.

Usage

Generate a project from a remote template:

Language: Shell
$ cookiecutter https://github.com/your-org/your-template

Render from a local template folder:

Language: Shell
$ cookiecutter path/to/template

Write output into a specific directory:

Language: Shell
$ cookiecutter -o ./projects https://github.com/your-org/your-template

Repeat a previous run using the saved replay file:

Language: Shell
$ cookiecutter --replay https://github.com/your-org/your-template

Choose a subdirectory with --directory:

Language: Shell
$ cookiecutter https://github.com/your-org/your-template --directory templates/library
Jinja Templating Engine

Tutorial

Primer on Jinja Templating

With Jinja, you can build rich templates that power the front end of your web applications. But you can use Jinja without a web framework running in the background. Anytime you want to create text files with programmatic content, Jinja can help you out.

intermediate django flask front-end web-dev

For additional information on related topics, take a look at the following resources:


By Leodanis Pozo Ramos • Updated July 18, 2026