Tools

Home
JSON FormatterSQL FormatterJS ValidatorMinify CSS
Merge PDFCompress PDFImage to PDF
JPG to PNGPNG to WebPCrop Image

HTML to Pug Converter

Paste HTML and instantly convert it to Pug (formerly Jade) template syntax with proper indentation, classes, IDs, and attributes

Your files never leave your browser
Input (HTML)0 chars, 0 lines
Output (Pug)0 chars, 0 lines
Ready·

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

Paste HTML
→
Parse DOM Tree
→
Output Pug

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.

INPUT
<nav class="main-nav"> <a href="/">Home</a> <a href="/about">About</a> </nav>
OUTPUT
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.

INPUT
<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>
OUTPUT
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.

INPUT
<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>
OUTPUT
.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

👨‍💻 Node.js Developers

Migrating existing HTML templates to Pug in Express.js or Koa apps.

🎨 Frontend Designers

Turning mockup HTML from Figma exports into Pug partials for a component library.

🎓 Students

Learning Pug syntax by seeing how familiar HTML maps to the template language.

🚀 Freelancers

Converting client-provided HTML pages into Pug for projects that already run on a Pug-based stack.

Common Mistakes

Pasting invalid or broken HTML

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.

Expecting inline styles to become Pug mixins

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.

Forgetting that Pug is whitespace-sensitive

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

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.

Share: