Skip to content
Tesserae

Keyboard shortcuts

Focus search
/
This help dialog
?
Run the current tool
Ctrl/⌘ +Enter
Copy the output (when an output is focused)
Ctrl/⌘ +C

Shortcuts are ignored while you are typing in an input, a textarea or a select.

Developer Utilities

HTML to Pug

Paste HTML and get equivalent Pug markup. Elements become indented selectors, id and class attributes collapse into #id and .class shorthand, remaining attributes keep their values, void elements stay self-contained, comments carry over as //-, and script/style/pre bodies become raw text blocks. Nested inline elements and mixed text are handled, with a warning for anything that cannot be represented exactly.

On-device No network Offline-ready

🔒 100% Client-Side & Private — processed locally in your browser. Files never leave your device.

Try:

Options

Your result will appear here

Type or paste your input above, adjust the options, then press Run. Tip: press Ctrl+Enter to run, and ? for every shortcut.

How it works

What it does

Paste HTML and get the equivalent Pug template. Elements become indented selectors, id and class attributes collapse into #id and .class shorthand, other attributes keep their values, void elements stay self-contained, comments carry over as //-, and script or style bodies become raw text blocks. The result renders as Pug source, and the notes say how many elements were converted.

When to use it

Reach for it when porting a static page into a Pug view layer. Rebuilding a finished page by hand inside an Express app is slow and easy to get wrong, and this keeps the nesting and shorthand selectors faithful.

The options

indentWidth sets the leading spaces from 2 to 8, quoteStyle switches attribute quoting between double and single, keepComments decides whether HTML comments survive as Pug comments, and inlineText controls whether an element with one text child keeps that text on the same line or moves it to a | line.

Caveats

Some markup has no exact Pug form, such as an element with both leading and trailing text siblings. Those cases still yield valid Pug with the text placed on separate | lines, and a warning appears in the notes. Input over 500,000 characters is refused, and a snippet containing no elements cannot be converted.

Privacy

Parsing and emitting are ordinary browser code, so your markup never leaves the tab and the page works with no connection. That matters when the HTML holds unpublished copy or internal URLs.

Questions

What happens to class and id attributes?

They become Pug shorthand: class="a b" turns into .a.b and id="x" becomes #x. A div with only classes or an id drops the tag name entirely, as in .card or #title.

How are script and style tags handled?

Their contents are emitted as raw text blocks using the trailing dot form (script. / style.), so JavaScript and CSS are not treated as markup or re-indented as Pug.

When is the output not exactly equivalent?

Pug cannot represent some HTML directly — for example an element with both leading and trailing text siblings, or mixed inline/block content in one line. Those cases still produce valid Pug, with the text moved to separate | lines and a warning listed in the notes.

See category