Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>Nifty Templates: Jinja, Twig & NunjucksNew to Visual Studio Code? Get it now.
Nifty Templates: Jinja, Twig & Nunjucks

Nifty Templates: Jinja, Twig & Nunjucks

Nifty

| (0) | Free
Jinja, Twig and Nunjucks: highlighting in HTML, YAML and any file, block formatting, outline and folding, unclosed-tag errors, completion with docs, snippets, and go to definition for templates.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Nifty Templates

Jinja, Twig and Nunjucks: highlighting in HTML, YAML and any file, block formatting, outline and folding, unclosed-tag errors, completion with docs, snippets, and go to definition for templates.

Maintained. No sign-in. No telemetry. Works in VS Code, Cursor, Windsurf, VSCodium and other editors that use Open VSX.

Features

A Flask Jinja template saved as .html, highlighted, with its blocks in the Outline

A missing endif reported at the if tag it leaves open

Filter completion after the pipe, with a short description of each filter

A messy partial after Format Document: block tags lined up and their contents indented

A docker-compose.yaml.j2 template with YAML highlighting and the template tags on top

  • Highlighting that works everywhere. Jinja, Twig and Nunjucks tags are highlighted in HTML templates, including inside attributes and <script> blocks, and in plain .j2 files such as Ansible YAML and config templates. Filters, tests, functions, strings and comments each get their own colour, and {% raw %} / {% verbatim %} content is left alone.
  • Unclosed-tag errors. {% if %} without {% endif %}, a stray {% endblock %}, or {% else %} outside an if or for is marked as you type, pointing at the tag that's wrong.
  • Completion. Tags (with snippets) after {%, with the right end… tag offered first. Filters after | and tests after is, for your dialect, each with a short description. Template paths inside extends, include, import and from.
  • Go to definition. Ctrl+click a template path to open it; paths are resolved from the file's folder, its parents and your template roots. Go from a {% block %} to the block it overrides in the parent template, and from a macro call to its {% macro %}.
  • Outline, folding and matching. Blocks and macros appear in the Outline view and breadcrumbs. Every block folds, including if/else branches. Putting the cursor on if, elif, else or endif highlights the whole set.
  • Hover docs for tags, filters and tests.
  • Format Document and Format Selection for HTML templates (Jinja HTML, Twig, Nunjucks). The formatter is deliberately conservative: it only changes the indentation at the start of lines, so each {% if %}, {% for %}, {% block %} or {% macro %} body sits one level inside its tag and {% else %} and {% end… %} line up with it. HTML is never reflowed or re-wrapped: inside each block it keeps the indentation you gave it, and <pre>, <textarea> and {% raw %} / {% verbatim %} content isn't touched. A template with unclosed tags isn't formatted until they're fixed. YAML and plain-text templates aren't formatted, because there the spaces before a tag end up in the output.
  • YAML templates. .yaml.j2, .yml.j2, .yaml.jinja and .yml.jinja2 files (Ansible, Salt, Kubernetes, docker-compose) get YAML highlighting with the template tags on top, # comments, and folding by indentation as well as by block.
  • Snippets for each dialect: if, ifelse, for, forelse, block, extends, include, import, from, macro, set, setblock everywhere, plus call, filter, with, trans and raw in Jinja, apply, embed, verbatim and use in Twig, and switch, asyncEach and raw in Nunjucks.
  • Knows your file types. .jinja, .jinja2, .j2, .html.j2, .yaml.j2, .twig, .html.twig, .njk and .nunjucks open in the right language, and Emmet works in them. When an .html file contains template tags, it offers to switch the file, or all .html files in the workspace, to Jinja or Twig.
  • Works in the browser on vscode.dev and github.dev.

Commands

Command What it does
Nifty Templates: Set Template Language for File Switch the current file to Jinja HTML, Jinja YAML, Twig, Nunjucks or plain Jinja

Settings

Setting Default What it does
nifty.templates.validate true Report unclosed, stray and misplaced block tags
nifty.templates.roots ["templates"] Folders where extends, include and import look for templates
nifty.templates.templateGlob HTML and template files Files offered when completing template paths
nifty.templates.suggestLanguage true Offer to switch .html files with template tags to a template language

For other file types, map them in files.associations, e.g. "*.html": "jinja-html" or "*.sls": "jinja-yaml".

Install

  • VS Code: search for "Nifty Templates" in the Extensions view, or install from the Visual Studio Marketplace.
  • Cursor, Windsurf, VSCodium, Kiro, Antigravity: install from Open VSX.

Privacy

This extension collects no telemetry and needs no account.

More Nifty tools

  • Nifty Beautify: Format HTML in PHP, Blade & Twig: Format HTML inside PHP, Blade, Twig, Jinja, Handlebars, ERB and Liquid templates without breaking the template tags. (Open VSX)
  • Nifty YAML: Formatter, Validator & Converter: Format YAML without losing comments (Kubernetes-style indents), sort keys, lint with yamllint, copy the key path, and convert to and from JSON. (Open VSX)
  • Nifty SQL: SQL Formatter for 20 Dialects: Format SQL in 20 dialects, including dbt and Jinja templates, with your team's settings. (Open VSX)
  • Nifty C# Templates: New Class, Record & Namespace: New C# class, interface, record, enum, test and controller files with the right namespace, plus namespace syncing. (Open VSX)
  • Nifty Docstrings: Doc Comments for Python, PHP, Rust and Go: Type three quotes under a Python function and get a Google, NumPy or Sphinx docstring with its arguments, types, returns and raises. PHPDoc, Rust and Go doc comments too. (Open VSX)
  • Nifty Format on Save: Toggle, Exclude & Chains: Control format on save: a status bar toggle, folders and files that are never formatted, time limits, and save chains like organize imports, ESLint fix, then format. (Open VSX)

See all 100+ Nifty extensions and web tools at https://getnifty.dev

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft