Pug to HTML Converter
CV-105Paste a static Pug template and get HTML. It handles tags, #id and .class shorthand, attributes, text, nesting and comments, but not code or variables.
Runs in your browser. Nothing is uploaded.
Pug (static templates only)
HTML
How to use it
- Paste your Pug.
- Choose Indented or One line output.
- Pick the indent size for the indented output.
- Press Pug to HTML, then copy or download.
What is supported
The converter reads the static part of Pug: tag names, #id and .class shorthand, attributes in parentheses with quoted strings, numbers, true, false and bare names, text after a tag, | text lines, tag. text blocks, nesting by indentation, tag: child chains, // and //- comments, doctype html, lines that start with <, and self-closing tags written as tag/. Plain text is written as is, and attribute values are escaped, which matches how Pug treats them.
What is not supported
This is not the full Pug compiler. Variables, expressions in attributes, code lines (-, = and !=), if and each, mixins, include and extends, filters, and #{...} or #[...] interpolation all return an error that names the line. That is on purpose: guessing at a value would give wrong HTML. For templates that use them, run the real Pug package with your data. Mixing tabs and spaces in the indentation is also an error.
Error messages and what to do
| Message | What it means | Fix |
|---|---|---|
Line 3: the indentation does not line up with the lines above it | A line is indented by an amount no parent line uses. | Indent by the same step as its sibling lines. |
Line 1: buffered code (= or !=) is not supported | The template outputs a value from code. | Replace it with plain text, or use the real Pug compiler. |
Questions people ask
How do I convert Pug to HTML?
Paste the Pug and press Pug to HTML. Nesting from your indentation becomes nested tags, and shorthand like #top.main turns into id and class attributes. Copy the HTML or download it.
Does it support variables and loops?
No. Code, each, if, mixins, include and extends are outside what this tool reads, and it reports the line instead of guessing. Use the Pug package in Node when your template needs data.
Is Jade syntax accepted?
Pug is the later name of Jade. This tool reads Pug syntax, so a simple static Jade template may convert, but features Jade-only are not specifically handled.
What does an attribute like disabled become?
A bare attribute is written in the short HTML form, so input(type="checkbox" disabled) becomes <input type="checkbox" disabled>. An attribute set to false is left out.
How are tabs and spaces treated?
Either works, but not both in one file, because the nesting depth cannot be read reliably. A mix gives an error with the line number.
About this tool
This reads the static part of Pug only; it is not the full Pug compiler. Supported: tags, #id and .class shorthand, attributes in parentheses with quoted strings, numbers, true, false and bare names, text after a tag, | lines, tag. text blocks, tag: nesting, // and //- comments, doctype html, lines that start with <, and self-closing tags written as tag/. Not supported, and each gives an error that names the line: variables, expressions in attributes, code lines (-, =, !=), if, each, mixins, include, extends, filters, and #{...} or #[...] interpolation. Plain text is output as written and attribute values are escaped, as Pug does. A bare attribute such as disabled becomes the short HTML form. Tabs and spaces must not be mixed in the indentation.