TXT to PDF: 5 Free Ways to Convert a Text File

November 11, 2026 · 10 min read

TXT to PDF: 5 Free Ways to Convert a Plain Text File

The quickest way to convert txt to pdf is to print the file to a PDF from the text editor you already have. On Windows, that's Notepad with Microsoft Print to PDF. On a Mac, it's TextEdit's Export as PDF. Linux takes one command. You don't need to upload the file anywhere.

Below you'll find exact clicks for each system, a command-line route, and Google Docs or Word for when you need fonts and margins. The last part covers pasting plain text into a Markdown to PDF converter without stray asterisks and hashes turning into formatting.

How Do You Convert TXT to PDF on Windows?

Windows 10 and 11 ship with a virtual printer called Microsoft Print to PDF. Any app that can print can save a PDF through it, and Notepad is the obvious one for a .txt file.

  1. Open the file in Notepad. Double-click it, or right-click and pick Open with, then Notepad.
  2. Press Ctrl+P, or choose File, then Print.
  3. Select Microsoft Print to PDF as the printer.
  4. Click Print, then pick a file name and folder in the save dialog.

That's the whole notepad to PDF route. If Microsoft Print to PDF isn't in the printer list, open Turn Windows features on or off and tick it there.

Got a log file with long lines? Open File, then Page setup, before printing and switch the orientation to Landscape. That gives each line more room before it wraps. If you're printing from a browser instead, our guide to printing a Markdown file covers the margin, scale and header settings there.

Converting a Text File to PDF on a Mac With TextEdit

TextEdit opens a .txt file as plain text, and it has a direct PDF command. Apple's TextEdit User Guide lists it with the other ways to convert a document.

  1. Open the file in TextEdit.
  2. Choose File, then Export as PDF.
  3. Name the file, pick a location and click Save.

To change paper size or orientation, choose File, then Page Setup before you export. The print dialog works too. Choose File, then Print, open the PDF pop-up menu and pick Save as PDF, as Apple's Mac guide to saving PDFs describes.

TXT to PDF on Linux and From the Command Line

If you have LibreOffice installed, it can convert text files with no window at all. This works on Linux, macOS and Windows.

soffice --headless --convert-to pdf notes.txt

That writes notes.pdf into the folder you ran it from. Add --outdir ~/pdfs to send it somewhere else, or use *.txt instead of a file name to convert a whole folder. These flags come from LibreOffice's own command-line parameters page.

On many Linux distributions, libreoffice works in place of soffice. On Windows and macOS, soffice may not be on your PATH. If your shell can't find it, call it by its full path inside the LibreOffice install folder.

On a Mac there's a second option that needs nothing extra, because macOS ships with the CUPS print system. Linux machines with CUPS have the same command, though turning text into PDF there also depends on the cups-filters package.

cupsfilter notes.txt > notes.pdf 2>/dev/null

The cupsfilter man page says PDF is the default output and the result goes to standard output, so you redirect it into a file. The 2>/dev/null part hides the DEBUG lines it prints to the terminal. We tested both commands on macOS with a small UTF-8 file, and each produced a one-page PDF.

Using Google Docs or Word When You Need Fonts and Margins

The built-in routes print in whatever font the editor uses and offer little layout control. If the PDF is going to a client or a printer, a word processor is worth the extra minute.

In Google Docs, paste the text into a new document, set the font and margins, then choose File, then Download, and pick the PDF option. In Microsoft Word on Windows, use File, then Save As or Save a Copy, and choose PDF from the file type list. On a Mac, Word puts PDF under File Format in the same dialog.

For logs, code or anything laid out in columns, switch to a monospace font such as Courier New. Every character then takes the same width, so columns line up again.

We prefer Docs or Word only when someone needs that layout control. For everything else, Notepad or TextEdit is the faster way to convert a text file to PDF, and it leaves your wording untouched.

Why Your Text Looks Different in the PDF

Plain text has no layout of its own, so whatever opens it decides how it looks. Most surprises come from these five things:

  • Long lines wrap. A 200-character log line won't fit across a portrait page. Landscape helps, and so does a smaller font.
  • Columns drift. Text lined up with spaces only stays lined up in a monospace font. A proportional font such as Arial makes an i narrower than an m.
  • Tabs change width. Each app sets its own tab stops, so tab-aligned tables can shift. Replacing tabs with spaces keeps them steady in monospace.
  • Characters turn into boxes or question marks. Save the file as UTF-8 first. Notepad's Save As dialog has an Encoding list where you can pick it.
  • The font lacks the script. Bengali, Arabic, Chinese and other non-Latin text needs a font that actually contains those glyphs, or you get empty squares.

Pasting Plain Text Into a Markdown to PDF Converter

The last route is the online notepad text to PDF approach. You paste the text into a browser editor and export it. Our Markdown to PDF converter works this way, and so does the editor through its Export as PDF option. Both take pasted text, not file uploads.

The catch is that a Markdown converter reads your text as Markdown. Characters that mean nothing in a .txt file suddenly carry instructions. Here's a plain note:

Meeting notes, 12 March
# of attendees: 6
* urgent: book the room
2026. A good year for the budget
Total cost: 5*3 = 15 and 2*4 = 8

We ran this through the same Markdown library our editor uses. The second line becomes a big heading that reads of attendees: 6. The third becomes a bullet point. The 2026. line turns into a numbered list starting at 2026, and the next line gets pulled into that list item. The two asterisks in the sums italicise everything between them.

Line breaks behave better than you might fear. Our preview keeps a single line break as a line break, so a short note keeps its shape. Several blank lines in a row still collapse into one paragraph gap, though, and runs of spaces collapse in the preview. A line indented four spaces after a blank line becomes a code block. Our Markdown line break guide explains the rules in full.

How to Keep Plain Text Exactly as Typed

You have three fixes, and you can mix them.

Wrap the whole thing in a fenced code block. Put a line of three tildes (or three backticks) above the text and another below it. Everything inside is shown as typed, in a monospace font, so column alignment survives too. The CommonMark spec defines both fence styles.

Escape the characters that cause trouble. A backslash before a symbol makes it literal:

\# of attendees: 6
\* urgent: book the room
2026\. A good year for the budget

Those three lines now render as ordinary text, and the backslashes don't show. Our guide to Markdown escape characters has the full list of symbols that need it.

Add a little Markdown on purpose. If the PDF is for other people, a real heading and a real list often look better than a raw text dump. Already have a .md file instead of plain text? See how to convert Markdown to PDF for the other methods.

Try both fixes below. The preview on the right shows how the escaped lines and the fenced table will look before you export anything.

Shopping list, 12 March
# of stores: 2
* Bring the receipt from last week
1. is the aisle number, not a list item

Item        Qty   Aisle
Milk        2     1
Coffee      1     7
Rice 5kg    1     12

Delete a backslash above and watch that line change.

48 words264 characters13 lines
Markdown

Which TXT to PDF Method Should You Use?

MethodInstall neededWorks offlineLayout controlKeeps columns
Notepad and Microsoft Print to PDFNoYesOrientation, marginsYes, monospace font
TextEdit Export as PDFNoYesPaper size, orientationDepends on font
LibreOffice or cupsfilterLibreOffice: yesYesDefaults onlyUsually
Google Docs or WordDocs: no, Word: yesWord: yesFullPick a monospace font
Markdown to PDF converterNoNoNoneOnly inside a code fence

One honest limitation of ours: the Markdown to PDF export always produces an A4 page with fixed 20 mm margins. There's no landscape, page size or margin setting. So for a wide log file, print from Notepad or TextEdit in landscape instead.

Each export uses one of the 3 free server operations you get per day, with no account needed. On the free plan, the editor's toolbar exports documents of up to 5,000 characters, and a long log can pass that quickly. Pro, at $6 a month, removes the daily cap and that character limit.

Quick Answers on Text Files and PDFs

Converting txt to pdf rarely needs an upload or new software. Notepad and TextEdit handle it in a few clicks, and LibreOffice or cupsfilter does it in one command. Docs or Word step in when you need fonts and margins. Want a heading or two as well? Paste the text, wrap the raw parts in a code fence and export it from the Markdown to PDF converter. To go the other way, our PDF to text guide shows how to pull the words back out of a PDF.