HTML to PUG Converter
Convert HTML to clean Pug (Jade) template syntax — paste, convert, and copy instantly.
Converted Pug will appear here...About HTML to PUG Converter
HTML to Pug Converter transforms standard HTML markup into Pug (formerly Jade) template syntax — the indentation-based language used in Node.js, Express, and many full-stack JavaScript frameworks. Instead of closing tags and angle brackets, Pug uses two-space indentation to express nesting. The converter handles the full vocabulary: element names, IDs and classes written as shorthand selectors (#id and .class), arbitrary attributes in parentheses, inline text, text-pipe blocks, comments, self-closing void elements, and the doctype declaration.
You would reach for this tool when migrating a legacy HTML front-end to a Pug-based Express project, when integrating a designer-supplied HTML mockup into an existing .pug view layer, or when learning Pug syntax by comparing known HTML with its equivalent output. The fragment mode is particularly useful for converting partial templates or component snippets: it skips the outer html and body wrappers and outputs only the inner markup, so the result drops directly into an existing layout file.
Every conversion runs entirely in your browser using the native DOMParser. No HTML is uploaded, stored, or transmitted, which means proprietary templates, internal dashboards, and client work remain on your machine. The tool is free with no account, no rate limit, and no file-size cap. Performance depends only on your device, not a remote server.
Key Features
ID and class shorthand
IDs and classes are written as #id and .class directly on the selector. A div with only classes or an ID omits the tag name entirely, matching how experienced Pug developers write components.
Attribute preservation
Non-class, non-id attributes — href, src, type, data-*, aria-* — are collected and rendered in Pug parenthesized syntax, with boolean attributes (e.g. disabled) kept as bare names.
Fragment mode
Toggle Fragment mode to strip the outer html and body wrapper and output only the inner content. This is the right default when you are converting partial templates or UI components rather than full documents.
Self-closing void elements
Void elements such as img, br, hr, input, meta, and link are rendered without child blocks, matching the Pug convention and preventing invalid output.
Comment passthrough
HTML comments are converted to Pug unbuffered comments (//) so developer notes survive the conversion and stay at the correct indentation level.
100% client-side and private
The DOMParser runs locally in your browser tab. No network request is made, which makes it safe for proprietary templates, internal tooling, and client codebases.
How to Use
Paste HTML
Copy your HTML code and paste it into the left input pane.
Convert
Click "Convert" to transform your HTML into Pug template syntax.
Copy Result
Use the copy button to grab your Pug output.
Example
A navigation snippet showing how IDs, classes, attributes, nested elements, and inline text are converted to Pug shorthand.
<nav id="main-nav" class="nav sticky">
<a href="/" class="logo">Acme</a>
<ul class="links">
<li><a href="/about">About</a></li>
<li><a href="/contact">Contact</a></li>
</ul>
<!-- skip to content -->
<button type="button" disabled>Menu</button>
</nav> #main-nav.nav.sticky
a.logo(href="/") Acme
ul.links
li
a(href="/about") About
li
a(href="/contact") Contact
// skip to content
button(type="button", disabled) Menu Common Use Cases
- arrow_circle_right
Migrating Express views from EJS or plain HTML
When switching an existing Express app to Pug views, convert each .html or .ejs file and drop the output into the views/ directory. The converter preserves all routing-critical attributes so hrefs and form actions survive intact.
- arrow_circle_right
Integrating designer mockups into a Pug project
Designers often deliver static HTML files. Convert the markup to Pug and paste it directly into the relevant layout or include file, keeping class names and data attributes exactly as specified.
- arrow_circle_right
Learning Pug by example
Paste any HTML snippet you already understand and compare it line-by-line with the Pug output. Seeing how nested divs, class lists, and attribute groups map to Pug syntax builds fluency faster than reading documentation alone.
- arrow_circle_right
Converting Bootstrap or Tailwind HTML snippets
Documentation and theme sites distribute components as plain HTML. Convert utility-class-heavy markup to Pug without losing any classes, then drop the block into a mixin or include.
- arrow_circle_right
Generating partial templates for server-side rendering
Use fragment mode to convert only the inner markup of a widget or card component. The output is ready to include in a larger Pug layout without extra wrapper elements.