The ultimate, lightning-fast auto close tag extension for Visual Studio Code.
Works across ALL file types with zero configuration: HTML, XML, XAML, JSX, TSX, Vue, Svelte, PHP, Blade, Astro, Markdown, and beyond!
Traditional auto-close extensions only work on standard HTML/XML and require clumsy <tag> syntax. Smart Close Tag elevates your coding productivity with universal language support, intuitive slash shorthand, attribute intelligence, void tag awareness, and real-time tag wrapping.
Whether you write React (JSX/TSX), Vue, Svelte, XAML/AXAML, PHP/Blade, Astro, XML, or custom template engines, Smart Close Tag works instantly out of the box with zero setup required.
| Trigger / Shortcut | Action | Result (| indicates cursor) |
| :--- | :--- | :--- |
| div/ + Tab / Enter | Single Tag Shorthand | <div>\|</div> |
| button class="btn btn-primary" id="submit"/ + Tab | Shorthand with Attributes | <button class="btn btn-primary" id="submit">\|</button> |
| img/ + Tab / Enter | Void / Self-Closing Tag | <img />\| |
| Component// + Tab / Enter | Force Self-Closing | <Component />\| |
| <section> (typing >) | Real-time Auto-Close | <section>\|</section> |
| </ (typing </) | Auto-Complete Matching Tag | Auto-completes the nearest open tag </tag> |
| Alt + W (or Option + W) | Wrap Selection with Tag | Wraps selected text/code inside custom tag |
Smart Close Tag is not restricted to HTML or XML. It activates smoothly across:
- Web Frontend: HTML5, React JSX, React TSX, Vue SFC (
.vue), Svelte, Astro, Angular templates - Mobile & Desktop: XAML (.xaml), Avalonia XAML (.axaml), MAUI, WPF
- Backend & Templates: PHP, Blade (.blade.php), Twig, Liquid, ERB, Smarty, ASP.NET, Handlebars
- Data & Markup: XML, SVG, MathML, RSS, Markdown (.md), and even unsaved (
untitled) files!
Simply type the tag name followed by a forward slash /, then press Tab or Enter.
div/ β <div>|</div>
Grid.Row/ β <Grid.Row>|</Grid.Row>
local:UserCard/ β <local:UserCard>|</local:UserCard>
custom-element/ β <custom-element>|</custom-element>Want attributes inside your tag before closing? Just type them naturally before /!
div class="container mx-auto" id="app"/
β <div class="container mx-auto" id="app">|</div>
input type="email" required placeholder="name@email.com"/
β <input type="email" required placeholder="name@email.com" />- Automatic Void Detection: Standard HTML void elements (
img,input,br,hr,meta,link, etc.) automatically generate self-closing tags<img />instead of redundant paired tags. - Double-Slash Shorthand: For any custom component or React element, simply append
//:
Avatar src={user.photo}// β <Avatar src={user.photo} />- Typing
>after<MyComponent>automatically inserts</MyComponent>and centers your cursor. - Typing
</scans backwards and completes the nearest unmatched open tag.
- Select any code block or text snippet.
- Press
Alt + W(Windows/Linux) orOption + W(macOS). - Type your desired tag (e.g.,
div class="card"orScrollView). - Press
Enterβ your selection is neatly wrapped with proper indentation!
Click the $(tag) Smart Tag: On item in the VS Code status bar to quickly toggle the extension, open configuration settings, or trigger tag wrapping.
Customize Smart Close Tag in File > Preferences > Settings (or press Ctrl+, and search for smartCloseTag):
| Setting | Type | Default | Description |
|---|---|---|---|
smartCloseTag.enable |
boolean |
true |
Enable or disable Smart Close Tag features globally. |
smartCloseTag.enableForAllFiles |
boolean |
true |
Enable Smart Close Tag across all file types (*). |
smartCloseTag.includedLanguages |
array |
["*"] |
List of language IDs where Smart Close Tag is active (supports * wildcard). |
smartCloseTag.excludedLanguages |
array |
[] |
List of language IDs to explicitly exclude (e.g. ["plaintext"]). |
smartCloseTag.enableAttributesSupport |
boolean |
true |
Allow typing attributes before / (e.g. div class="box"/). |
smartCloseTag.enableAutoCloseOnGreaterThan |
boolean |
true |
Automatically insert matching closing tag when typing >. |
smartCloseTag.enableAutoCloseOnSlash |
boolean |
true |
Automatically complete matching closing tag when typing </. |
smartCloseTag.selfClosingFormat |
string |
"slash" |
Self-closing format: "slash" (<img />) or "void" (<img>). |
smartCloseTag.selfClosingTags |
array |
[] |
Additional custom tag names to treat as self-closing void elements. |
smartCloseTag.showStatusBarItem |
boolean |
true |
Show the Smart Close Tag status bar indicator. |
| Shortcut | Command | When |
|---|---|---|
Alt + W (Win/Linux) / Option + W (Mac) |
smartCloseTag.wrapWithTag |
In editor with text selected |
Tab or Enter |
Accept Tag Expansion | When autocomplete dropdown displays tag snippet |
| Feature | Built-in VS Code | Auto Close Tag | Smart Close Tag Pro |
|---|---|---|---|
Works in ANY file type (*) |
β | β (HTML/XML only) | β Full Universal |
TagName/ Shorthand |
β | β | β Yes |
Tag with Attributes (tag class="x"/) |
β | β | β Yes |
Double Slash Self-Closing (Tag//) |
β | β | β Yes |
Void Element Recognition (img, input) |
Partial | β | β Fully Configurable |
Auto Close on > |
HTML only | β | β Universal |
Auto Complete on </ |
HTML only | β | β Universal |
Wrap Selection with Tag (Alt+W) |
β | β | β Built-in |
| Interactive Status Bar & Quick Menu | β | β | β Included |
- Open Visual Studio Code.
- Press
Ctrl + Shift + X(orCmd + Shift + Xon macOS) to open the Extensions view. - Search for
Smart Close Tag(orNguyenTungSk2004.smart-close-tag). - Click Install.
Press Ctrl + P (or Cmd + P on macOS) and run:
ext install NguyenTungSk2004.smart-close-tagcode --install-extension NguyenTungSk2004.smart-close-tagIf Smart Close Tag saves you time and boosts your productivity, please consider giving it a 5-star review on VS Code Marketplace and starring the GitHub repository! Your support helps the extension reach more developers worldwide.
Contributions, bug reports, and feature requests are very welcome! Please check out our Contributing Guide to get started.
- GitHub Repository: https://github.com/NguyenTungSk2004/smart-close-tag
- Report Issues: Issue Tracker
This extension is licensed under the MIT License.
Made with β€οΈ by NguyenTungSk2004.