FormatterHQ

Pug to HTML Compiler

Paste a Pug template or open a .pug file and get the HTML it produces. Handles tags, shortcuts, attributes, block text, static interpolation and comments.

Input TEXT
Output HTML
Ready.

How to use the Pug to HTML Converter

  1. Paste your Pug template or open a .pug or .jade file.
  2. Keep pretty printing enabled for indented HTML, or turn it off for compact output.
  3. Compile the template.
  4. Copy the HTML or check the error message, which includes the line number of any problem.

Compile Pug to HTML without Node.js

Pug is normally compiled on the server or during a build. When you only want to see what a template produces, check a snippet from documentation, or convert a Pug file into plain HTML for a project that does not use Pug, this Pug to HTML converter does it in the browser with no installation.

Example

doctype html
html(lang="en")
  head
    meta(charset="utf-8")
    title My Pug Page
  body
    //- this comment is not rendered
    header#top.site-header
      h1 Welcome, #[em friend]!
      a.button(href="/start", target="_blank") Get started
    p.
      Block text keeps
      several lines together.
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>My Pug Page</title>
  </head>
  <body>
    <header class="site-header" id="top">
      <h1>Welcome, <em>friend</em>!</h1><a class="button" href="/start" target="_blank">Get started</a>
    </header>
    <p>Block text keeps several lines together.</p>
  </body>
</html>

The pretty printer keeps inline elements such as links next to their neighbors and joins block text into a single line. Both render exactly the same in a browser as the multi-line form.

Supported Pug syntax

  • Tags, nesting by indentation and block expansion (li: a(href="/") Home).
  • #id and .class shortcuts, with div implied when the tag is omitted.
  • Attributes in parentheses, separated by commas or spaces, including boolean attributes and static object or array values for class and style.
  • Piped text (| text), block text with a trailing dot (p.) and inline HTML lines.
  • Interpolation with static values: #{"text"} (escaped), !{"<b>raw</b>"} (unescaped) and tag interpolation #[strong bold].
  • Buffered comments // (output as HTML comments) and unbuffered comments //- (removed).
  • doctype shortcuts such as html, xml, strict and transitional.

What is not supported

This is a static compiler: it converts markup, but it does not execute JavaScript. Lines that need runtime data or other files produce a clear error with the line number:

  • Code lines (- var x = 1) and buffered expressions that reference variables (= user.name).
  • Conditionals and loops: if, unless, each, while, case.
  • Mixins (mixin, +button), include, extends and block.
  • Filters such as :markdown.

Literal values are fine, so = "Hello" and #{'2026'} work. For templates full of logic, compile them with the official pug package in Node.js, where your data is available.

Common errors

  • Inconsistent indentation – mixing tabs and spaces, or indenting a child by a different amount than its siblings, changes the nesting. Pick one style per file.
  • Text on the next line – text placed on its own line under a tag needs a pipe (| text); otherwise Pug treats the first word as a tag name.
  • Unclosed parentheses – long attribute lists may span lines, but every ( needs its ).

Related tools

Convert in the opposite direction with HTML to Pug, preview the compiled page in the HTML viewer, or tidy the output further with the HTML formatter. Templates are compiled locally and never uploaded.

Frequently asked questions

Can I compile Pug templates that use variables?
Only when the values are literals. Expressions that reference variables, loops, conditionals and mixins need real data and a JavaScript runtime, so the tool reports them as unsupported.
Does this work for Jade files?
Yes. Jade is the former name of Pug and uses the same syntax, so .jade files compile the same way.
Why is my text treated as a tag?
In Pug, the first word of a line is a tag name. Put text after the tag on the same line, or start a separate text line with a pipe character.
What does the pretty option do?
It indents the generated HTML for readability. Turn it off to get compact HTML without extra whitespace.
Is my template uploaded?
No. The template is parsed and compiled in your browser and never leaves your device.

Last updated September 26, 2026

Related tools

HTML to Pug Converter Convert HTML to Pug template syntax: indentation-based tags, #id and .class shortcuts, attributes and text blocks. BBCode to HTML Converter Convert forum BBCode such as [b], [url], [quote], [list] and [code] into clean, safe HTML markup instantly. CSV to HTML Table Converter Convert CSV to HTML online for free. Get clean table markup with a live preview. Excel to HTML Table Converter Convert Excel to HTML online for free. Get clean table markup with a live preview. HTML Entities to Text Turn HTML entities (named, decimal and hex) back into plain Unicode text. HTML to BBCode Converter Convert HTML into forum-friendly BBCode: bold, links, images, lists, quotes, tables, code blocks and inline colours. Responsive Website Tester Preview any website on phone, tablet, laptop and desktop screen sizes side by side to check your responsive design. Text to HTML Converter Paste formatted text from Word, Google Docs or a web page, or type plain text, and get clean HTML code. Removes inline styles, classes and Word markup. Word to HTML Converter Convert Word .docx documents to clean, semantic HTML with headings, lists, tables, links and images — right in your browser. Code Syntax Highlighter Highlight source code as self-contained HTML with inline styles - paste the coloured snippet into blogs, e-mails or docs. HTML Entities List Searchable list of 1,400+ named HTML character entities with decimal and hex codes, code points and CSS escapes. Click to copy. HTML Formatter Beautify or minify HTML online. Fixes indentation of tags, inline CSS and scripts.