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

Code to PDF Converter

Turn HTML, CSS, JavaScript or any code file into a clean, readable PDF with syntax highlighting and line numbers. Your code stays on your device.

  • Syntax highlighting
  • Real selectable text
  • Files stay on your device

Loading Code to PDF…

How to Use

How to Convert Code to PDF

Go from source files to a printable PDF in four steps.

  1. 1

    Step 1: Add Your Code

    Upload one or more files, a whole folder, or paste code into the editor.

  2. 2

    Step 2: Check the Language

    The language is detected from each file's extension. You can change it for any file.

  3. 3

    Step 3: Choose the Look

    Pick a theme, font size, line numbers, page size, margins and header.

  4. 4

    Step 4: Download

    Check the preview and download one PDF, or separate PDFs in a ZIP.

Guide

Why turn code into a PDF?

Code is easiest to read in an editor, but an editor isn't always there. Students hand in assignments as PDFs, reviewers mark up printouts, and teams keep a copy of the exact source that shipped. A PDF opens on any phone or computer, looks the same everywhere, and can be printed, shared or archived without anyone needing your project set up.

This converter keeps code looking like code: a clear monospace font, syntax colours, line numbers and the file name at the top of every page. If you want the finished web page rather than its source, use HTML to PDF instead.

Real text, not screenshots

Many tools print code as pictures, which makes the PDF large and impossible to search. Here every character is real text in an embedded font. You can search for a function name, select a few lines and paste them into your editor with the indentation intact. Line numbers are drawn in the margin and are left out when you copy, so the snippet works straight away.

Tabs are turned into spaces at the tab width you choose, so columns line up exactly as in your editor. Comments in Urdu, Arabic and other languages are kept with a matching fallback font.

Settings explained

  • Theme: Light, GitHub Light or Solarized Light for paper, or Dark for reading on screen. The dark theme fills each page with colour, so avoid it if you print.
  • Font size and line numbers: from 6 to 14 points, with numbers on or off.
  • Long lines: wrap onto the next row with a small arrow, or shrink the text of that file until the longest line fits.
  • Page: A4 or Letter, portrait or landscape, with narrow, normal or wide margins. Landscape suits code with long lines.
  • Header and footer: the file name at the top, “Page 1 of N” at the bottom, and the date if you like.

Several files and whole folders

Add as many files as you need, or upload a folder. Files are sorted by path, and each keeps its folder in its title, such as src/utils/date.ts. Folders such as node_modules and .git are skipped, as are pictures and other files that aren't text.

Choose One PDF to get a single document that starts with a clickable contents page. Each file begins on a new page and has its own bookmark, so you can jump straight to it in any PDF reader. Choose Separate PDFs to get one PDF per file, packed in a ZIP with the same folders. Afterwards you can merge PDFs, compress a large one, or add a password.

Private and safe

Your files never leave your device. They are read by your browser and never uploaded. The code is only coloured, never run, so even a script you don't trust is safe to convert. A large file is handled in the background, so the page keeps working while the PDF is made.

Features

Why Use This Code to PDF Converter?

Printable code that still works as text.

  • Syntax Highlighting

    Keywords, strings and comments are coloured for more than 25 languages.

  • Real, Copyable Text

    Nothing is turned into a picture. Copy code back out with its indentation.

  • Line Numbers

    Numbers sit in a margin and are not copied along with the code.

  • Long Lines Handled

    Wrap long lines with a marker, or shrink the text so each line fits.

  • Whole Folders

    Upload a project folder. Paths are kept, and node_modules and .git are skipped.

  • Contents and Bookmarks

    Several files get a clickable contents page and a bookmark for each file.

  • Clear Monospace Font

    An open-source monospace font is embedded, so the PDF looks the same everywhere.

  • Private and Safe

    Your code is never uploaded and never run. Everything happens in your browser.

FAQ

Frequently Asked Questions

Answers to common questions about Code to PDF on ToolCube.

How do I convert a code file to PDF?

Upload the file, or drag it onto the page. The language is detected from the extension and the preview appears straight away. Choose a theme and page settings, then press Download PDF. The file is named after your file, such as index-code.pdf.

Which languages and file types are supported?

HTML, CSS, SCSS, JavaScript, TypeScript, JSX and TSX, JSON, XML and SVG, Markdown, Python, Java, C, C++, C#, PHP, Ruby, Go, Rust, Kotlin, Swift, SQL, YAML, shell scripts and plain text. Any other text file can be added as plain text.

Can I copy code from the PDF?

Yes. The PDF holds real text in an embedded monospace font, so you can search it and copy it. Spaces and indentation are kept as real characters, and line numbers are drawn separately so they are not copied with the code.

How do I convert a whole project or folder?

Press Upload a folder, or drag the folder onto the page. Every text file is added with its folder path, and folders such as node_modules and .git are skipped. You get one PDF with a contents page and bookmarks, or separate PDFs in a ZIP.

What happens with very long lines?

Choose Wrap to continue a long line on the next row, marked with a small arrow so you can tell it apart from a new line. Or choose Shrink to fit, which makes the text of that file smaller until its longest line fits the page.

Why can't I enter the path to a file on my computer?

Websites can't open files on your computer by their path, for your own safety. Select the file with Browse Files, or drag it onto the page. It is read directly by your browser.

Why are some files skipped?

Pictures, fonts, archives and other binary files can't be shown as code, so they are left out and listed. Files larger than 5 MB are also skipped, as a PDF of that much code would run to thousands of pages.

Is my code uploaded anywhere?

No. Highlighting and PDF creation run entirely in your browser, and your code is never run. It is safe for private projects and work under a confidentiality agreement.