Skip to main content
ToolCube – All tools at one place.

HTML Source Code to PDF

Need the markup itself on paper, not the finished web page? Turn HTML source into a highlighted, line-numbered PDF in a few seconds.

  • Shows the code, not the page
  • Line numbers
  • Processed in your browser

Loading Code to PDF…

Guide

The code, not the page

Most HTML to PDF tools render the page: you get the headings, pictures and layout a visitor would see. Sometimes you need the opposite. A teacher marking a web design assignment, a developer reviewing a pull request on paper, or a team archiving the exact markup behind a landing page all want to read the source itself, tag by tag.

This page does exactly that. Tags, attributes and values are coloured differently, and CSS inside style tags and JavaScript inside script tags are highlighted in their own languages. Nothing in the file is run or loaded, so the PDF shows the code as you wrote it.

If you want the finished page as a PDF instead, use HTML to PDF, which renders the HTML with its styles and images.

Readable on paper and on screen

Line numbers make it easy to point at a problem, such as a missing closing tag on line 48. Long lines, common in HTML with many classes, can wrap with a small marker or shrink to fit. The text is set in an embedded monospace font, and it stays real text: you can search the PDF or copy a snippet back into your editor with its indentation.

For a whole site, press Upload a folder. Each HTML, CSS and JavaScript file is added with its path, and you get one PDF with a clickable contents page and a bookmark for each file. More options are on the main Code to PDF page.

Private by design

When the PDF is ready, you can add a password with Protect PDF or combine it with other documents using Merge PDF.

Your files never leave your device. HTML Source Code to PDF runs entirely in your browser.

FAQ

Frequently Asked Questions

Answers to common questions about HTML Source Code to PDF on ToolCube.

Does this render my HTML page?

No. It shows the HTML source code with syntax highlighting. To turn the finished page into a PDF, use HTML to PDF.

Is the CSS and JavaScript inside my HTML highlighted?

Yes. Code inside style and script tags is highlighted as CSS and JavaScript. Scripts are never run.

Can I save the HTML of a website I'm viewing?

Press Ctrl+U (Cmd+Option+U on a Mac) to view the page source, then copy it and paste it here. Or save the page with Ctrl+S and upload the .html file.

Can I copy the code back out of the PDF?

Yes. The PDF holds real text, so you can select and copy it with its indentation. Line numbers are not copied.