HTML to Pug Converter (Indented Template Syntax)

Translates HTML into Pug syntax, keeping structure, attributes, comments and script and style blocks.

Use the tool

Why this tool exists

Moving a static page into a Pug-based project by hand means rewriting every tag. The structure is mechanical, so a tool can do it.

The converter writes classes and ids in shorthand when they are simple names, keeps unusual class strings such as md:flex as attributes, writes script and style as dot blocks, and uses piped lines for text next to tags. I compiled the results with Pug and compared with the input: they matched apart from attribute order and quoting. Whitespace between inline elements can differ slightly, so look at the page after converting.

How to use it

  1. Paste HTML.
  2. Choose the indent.
  3. Copy the Pug.
  4. Compile it in your project and check the page.

Frequently asked questions

Does it handle inline tags in text?

Yes, using piped text lines and child tags. Check spacing around them.

What about template variables?

The input is plain HTML. # { and #[ in text are escaped so Pug does not treat them as interpolation.

Can it convert back?

Compile with Pug itself; this tool only goes from HTML to Pug.