Blog
Image Tools
Crop Image
Resize Image
Rotate & Flip
Compress Image
Photo Filters
Meme Generator
GIF Maker
Collage Maker
Watermark Image
Blur Image
Convert
JPG to PNG
PNG to JPG
HEIC to JPG
DNG to JPG
Image Converter
PDF to JPG
JPG to PDF
Merge PDF
Compress PDF
MP4 to MP3
Video to GIF
MOV to MP4
MP3 Converter
Video & Audio
Trim Video
Crop Video
Remove Audio
Text to Speech
Audio Cutter
MP3 Compressor
Design & Editor
Resume Builder
Design Editor
Add Text to Photo
Social Media Resizer
QR Code Generator
Signature Generator
More Tools
Word Counter
Password Generator
Random Picker
Dice Roller
Spinner Wheel
Favicon Generator
Barcode Generator
Browse All Tools

HTML to Pug Converter

Turn HTML into clean Pug templates in a second. Closing tags disappear, nesting becomes indentation, classes and ids use the short .class and #id style, and short text stays on the same line as its tag.

100% Free
No Sign-up
HTML → Pug
Instant
Private · Nothing Saved Online
HTML to Pug
Your Text
Input Characters—
Output Characters—
Lines In → Out—
Input Words—
Type or paste in the input box, or open a file. The result updates as you type.
Pug to HTML
HTMLType, paste or drop a file
Pug
Input—
Result—
Status—
Settings forYour markup
Pug Output
File Name

How to Convert HTML to Pug

Quick answer: paste your HTML or open a file; the Pug appears below. Copy it or download the .pug file.

  1. 1

    Add your HTML

    Paste it or open a file.

  2. 2

    Choose options

    Adjust the output on the right.

  3. 3

    Check the Pug

    It updates as you type.

  4. 4

    Copy or download

    Save it as .pug.

What You Get

Instant
Updates as you type
Clean Output
Valid Pug
Options
Format it your way
Clear Errors
Problems explained
100% Private
Nothing is uploaded
Any Device
Phone or computer

What Is HTML?

HTML is the language every web page is written in. Elements are marked with opening and closing tags, such as paragraphs, headings, links, images, lists and tables, and browsers turn them into the pages you see. Every website builder, content system and email editor accepts HTML.

What Is Pug?

Pug is a template language that writes HTML with indentation instead of closing tags. A line such as a.button(href="/shop") Buy now becomes a full link element, nesting is shown by indenting, and loops, conditions and variables can generate repeated parts of a page. Many websites and web apps use Pug templates because they are short and easy to read.

Why Convert HTML to Pug?

Moving an existing page into a Pug project by hand is slow and easy to get wrong. Converting gives you a correct starting template instantly, which you can then split into layouts and mixins. It is also a quick way to learn Pug by comparing HTML you know with its Pug version.

How the Conversion Works

Your HTML is read by the browser's own HTML reader, so even untidy markup with missing closing tags is understood the same way a browser would. Each element becomes a line with its tag name, ids and classes as shortcuts, and other attributes in brackets. Text goes after the tag or on its own line with a pipe, comments become Pug comments, and script, style and pre contents are kept exactly as blocks.

Example

The sample page becomes a short template: header.top contains h2#title and a p with the strong text inline, ul.products holds the list items, and the link becomes a.button(href='/shop') Shop now. The doctype line is kept at the top.

Tips

Div elements with an id or class are written as just #id or .class, which is standard Pug. Turn off the shortcuts option if you prefer every attribute in brackets. Check inline formatting such as links inside sentences, which Pug writes as separate lines.

Who Uses It?

Developers adopting Pug, students, and teams converting existing pages into templates. Because the text never leaves the device, it is also safe for drafts and internal documents.

Step by Step

Paste your HTML into the input box, drop a file onto it, or press Open File. The Pug appears in the output box straight away and updates as you type, so you can fix mistakes and watch the result change. Adjust the options on the right if needed. When it looks right, press Copy to put the result on your clipboard, or Download to save it as a .pug file. Press Sample at any time to see an example.

Using Your Pug

Save the template with the .pug extension in your project's views or templates folder. From here you can split repeated parts such as headers and footers into separate files with include, replace repeated items with each loops, and turn hard-coded text into variables passed in by your application. Compile it once to check the result matches the original page before replacing it. Keep indentation consistent, using the same number of spaces throughout the file.

Private, Free and Instant

The converter is free, with no sign-up and no limit beyond the 5 MB text size. Everything runs in your browser, so drafts, internal documents and unpublished content are never uploaded or stored. It works on Windows, Mac, Linux and Chromebooks, and on phones and tablets.

HTML to Pug: Writing Templates Without Angle Brackets

Pug, once called Jade, is a template language for Node.js. It uses indentation instead of closing tags and has variables, loops and includes.

What conversion looks like

<div class="card"><h2>Title</h2></div> becomes div.card with an indented h2 Title line. Ids use a hash, as in div#main, and attributes go in brackets.

Tip

Check the indentation, because Pug uses it to define structure. To turn Pug back, see Pug to HTML.

Frequently Asked Questions

Questions about HTML to Pug

How do I convert HTML to Pug?

Paste your HTML or open the file. The Pug appears straight away; copy it or download it.

Is the output valid Pug?

Yes. It follows standard Pug syntax and compiles back to equivalent HTML.

Does it keep comments?

Yes. HTML comments become Pug comments.

Is there a size limit?

Text up to 5 MB.

Does it work on my phone?

Yes. It works in modern browsers on phones, tablets and computers.

Is my text uploaded?

No. The conversion runs in your browser on your own device. Nothing is sent or stored.