.twig
🌐 WebText-based

.twig File — Twig Template

text/x-twig

File Inspector

Drop any file to identify its extension and type — runs entirely in your browser

TWIG

Drop a .twig file here or click to choose

Or drop any file to identify its extension

Expected MIME type:text/x-twig

Quick Facts

Extension.twig
Full NameTwig Template
MIME Typetext/x-twig
CategoryWeb
TypeText-based (human-readable)
Typical Size1 KB – 20 KB
First Appeared2009

What Is a .twig File?

Twig is a modern template engine for PHP, created by Fabien Potencier (creator of the Symfony framework). TWIG files use a syntax inspired by Jinja2 (Python) with {{ }} for expressions, {% %} for statements, and {# #} for comments. Twig provides template inheritance (extends/block pattern), includes, macros (reusable template functions), filters for value transformation, tests for conditional checks, and automatic output escaping for XSS prevention. The template inheritance system allows defining base layouts with overridable blocks, enabling clean template hierarchies. Twig compiles templates to optimized PHP code for production performance. The engine is the default template engine for Symfony, one of the most popular PHP frameworks, and is also used by Drupal 8+, Craft CMS, and Grav CMS. Twig's sandboxing feature restricts which tags, filters, and functions are available in untrusted templates. The language supports internationalization through the trans tag, and custom extensions can add project-specific functionality. Twig's design balances power with security, providing enough features for complex template logic while preventing template authors from introducing security vulnerabilities.

How to Open .twig Files

VS Code (with Twig extension)
PhpStorm
Sublime Text
any text editor

Related File Extensions

More Web File Extensions

Other web formats you might encounter

Browse File Extensions by Category

Explore our reference of 259 file extensions with details, programs, and related formats.