HTML to Pug Converter
Paste HTML and instantly convert it to Pug (formerly Jade) template syntax with proper indentation, classes, IDs, and attributes
Paste any HTML — a full page, a single component, something you grabbed from DevTools — and get clean Pug syntax back in one click. Classes turn into dot notation, IDs get hash prefixes, and nesting is handled through indentation instead of closing tags.
Pick your indent size, toggle div shorthand on or off, and decide whether attributes get commas. And everything runs in your browser. Nothing gets uploaded.
How It Works
The browser's built-in DOMParser reads your HTML and builds a tree. Then the converter walks each node — tags become Pug identifiers, classes switch to dot notation, IDs get a hash prefix, and child elements indent one level deeper. Text nodes either sit inline or use the pipe character. The whole thing takes milliseconds, even on full-page markup.
Examples
Simple Navigation Bar
Converting a basic nav with links and a class.
<nav class="main-nav">
<a href="/">Home</a>
<a href="/about">About</a>
</nav>
nav.main-nav
a(href="/") Home
a(href="/about") About
Form with Input Fields and a Button
A login form — notice how self-closing inputs and nested elements both convert correctly.
<form id="login" class="form-card">
<label for="email">Email</label>
<input type="email" id="email" placeholder="[email protected]" />
<label for="pw">Password</label>
<input type="password" id="pw" />
<button type="submit">Log In</button>
</form>
form#login.form-card
label(for="email") Email
input(type="email", id="email", placeholder="[email protected]")
label(for="pw") Password
input(type="password", id="pw")
button(type="submit") Log In
Card Component with Image and Text
A product card with an image, heading, paragraph, and a link. Div shorthand kicks in here — the wrapper div disappears.
<div class="card">
<img src="shoe.jpg" alt="Running shoe" />
<div class="card-body">
<h3>Trail Runner Pro</h3>
<p>Lightweight and grippy.</p>
<a href="/buy" class="btn">Buy Now</a>
</div>
</div>
.card
img(src="shoe.jpg", alt="Running shoe")
.card-body
h3 Trail Runner Pro
p Lightweight and grippy.
a.btn(href="/buy") Buy Now
Who Uses This
Migrating existing HTML templates to Pug in Express.js or Koa apps.
Turning mockup HTML from Figma exports into Pug partials for a component library.
Learning Pug syntax by seeing how familiar HTML maps to the template language.
Converting client-provided HTML pages into Pug for projects that already run on a Pug-based stack.
Common Mistakes
Missing closing tags or mismatched nesting confuses the parser. The browser's DOMParser will attempt to fix it, but the Pug output may not match what you expected. Clean up your HTML first, or at least check for unclosed tags.
This is a syntax converter, not a refactoring tool. Inline styles stay as style attributes in the Pug output. You will still need to move them into a stylesheet yourself.
After converting, if you edit the Pug output and mix tabs with spaces, Pug will throw compile errors. Stick to one indent style. The tool defaults to 2-space indentation, which is what most Pug projects use.
Technical Details
- Processing: 100% client-side — uses the browser DOMParser API
- Browser Support: Chrome, Firefox, Safari, Edge
- Input Limit: No hard limit; tested with 5,000+ lines of HTML
- Output Options: 2 or 4 space indent, div shorthand toggle, comma-separated attributes
Frequently Asked Questions
What is Pug and how is it different from Jade?
Same thing, different name. The project was called Jade until 2015, when a trademark issue forced a rename to Pug. The syntax, the compiler, the ecosystem — all identical. If you see old tutorials referencing Jade, just read "Pug" instead.
Can I convert an entire HTML page including head and body?
Yes. Paste the whole thing — doctype, head, body, scripts, all of it. The converter handles the full document structure. The doctype line becomes doctype html in Pug, and everything else nests normally underneath.
Does the converter handle inline JavaScript and CSS?
Script and style blocks get converted into Pug script and style tags. The content inside them stays as-is. Pug doesn't transform your JS or CSS — it just wraps them in the right Pug tag with proper indentation.
Why does my Pug output look different from what I expected?
Usually it is because the HTML had issues — unclosed tags, weird nesting, or extra whitespace. The browser's parser auto-corrects broken HTML before the converter sees it. Fix your HTML first and run it again. Also check that your div shorthand and comma settings match what you want.
Is this tool free to use?
Completely free, no account needed, no limits on how many times you convert. There are no ads either. Bookmark it, use it whenever you need it.