← All Guides
Documents to PDF

How to Convert a Text File (.TXT) to PDF

πŸ“… April 4, 2026 ⏱ 8 min read ✍️ BuildPDF Team

Plain text files (.txt) are one of the oldest and most universal file formats β€” lightweight, compatible with everything, and easy to create. But when you need to share or print a text file professionally, PDF is the standard. Converting a .txt file to PDF gives you control over page formatting, font size, and margins.

With BuildPDF, this conversion takes under a minute and happens entirely in your browser β€” no software, no sign-up, no upload.

How to Convert TXT to PDF

01

Go to BuildPDF

Open buildpdf.co in any modern browser β€” Chrome, Firefox, Edge, Safari, or Brave.

02

Upload your .txt file

Drag and drop your text file onto the converter, or click "Choose Files" to browse. You can also select multiple .txt files to merge them into one PDF.

03

Adjust formatting

Use the options panel to set page size (A4 or Letter), orientation (Portrait for most text documents), and margin size. A Normal (10mm) margin gives a clean, readable look.

04

Convert and download

Click "Convert to PDF." Your text is paginated and rendered as a PDF in your browser. Click Download to save it.

Common Use Cases: Why Convert TXT to PDF?

πŸ“œ Sharing Notes or Logs

Convert developer logs, meeting notes, or plain-text notes to a shareable, professionally formatted PDF.

πŸ“‹ README Files

Turn a project's README.txt into a PDF to include in a deliverable package or client handoff.

βš–οΈ Legal Text

Convert terms, agreements, or policy drafts from plain text into print-ready PDF format.

πŸŽ“ Academic Writing

Submit essays or writing assignments that were saved as .txt files as properly formatted PDFs.

Tips for a Better Result

Choose the right margin

For most text documents, a Normal (10mm) margin produces the most readable result. If you want more text per page, try Narrow (5mm). For official-looking documents like letters or reports, Wide (20mm) margins are more professional.

Long text files and page breaks

BuildPDF automatically paginates your text β€” splitting long .txt files across as many pages as needed. The converter handles line wrapping based on the page width, so you don't need to manually format anything in your text file.

What about encoding?

BuildPDF reads .txt files as UTF-8, which is compatible with virtually all modern text files, including those with accented characters (Γ©, ΓΌ, Γ±, etc.), symbols, and emoji. If your file uses a legacy encoding (like Windows-1252), and characters look wrong in the PDF, re-save the file as UTF-8 in Notepad or a text editor first.

πŸ’‘ Tip: If your text file contains code (Python, JavaScript, etc.), BuildPDF will preserve the monospace formatting. The converted PDF is great for sharing code samples or configuration files in a readable, printable format.

The Encoding Problem: UTF-8, ASCII, and Windows-1252

Plain text files carry no universal declaration of their encoding β€” it's simply not part of the .txt format. A file created on a Windows machine in the 1990s may use Windows-1252 (a Western European single-byte encoding), while a modern file from Linux or macOS is almost certainly UTF-8. Both are valid, but they are not interchangeable.

BuildPDF reads all .txt files as UTF-8. The problem arises with legacy files: a Windows-1252 file containing characters like curly quotes, em-dashes, or the copyright symbol will display as garbled characters (mojibake) in the PDF because those byte sequences mean different things in UTF-8.

The fix is straightforward. Open the file in Notepad (Windows) and use File β†’ Save As, then change the Encoding dropdown from "ANSI" to "UTF-8." On macOS, TextEdit handles this automatically when you re-save. VS Code, Notepad++, and Sublime Text all have encoding conversion built in β€” look for "Save with Encoding" in their menus.

How BuildPDF Handles Line Breaks and Pagination

Plain text files use one of three line-ending conventions: LF (Unix/macOS), CRLF (Windows), or CR (old Mac). BuildPDF normalises all three β€” you don't need to worry about which system created the file.

When paginating, BuildPDF flows the text into the page width you've set, wrapping lines that are too long and adding new pages when the text fills the current one. This is word-wrap pagination β€” so a file formatted for an 80-column terminal may look slightly different in the PDF depending on font size and margin settings.

One important limitation: BuildPDF does not interpret form-feed characters (\f) as page breaks. If your text file relies on form-feed for manual pagination (common in legacy printer output), those characters will be ignored. For fine-grained pagination control, consider converting the file to DOCX in a word processor first, then using BuildPDF's DOCX-to-PDF converter.

πŸ’‘ Preserving alignment: If your .txt file contains ASCII art, tables drawn with pipe characters, or code aligned with spaces, the PDF output will only look correct with a monospace font. Courier is the safe default β€” all characters are equal width so columns align perfectly.

Content Types and How to Handle Each

Code files and scripts

Python, JavaScript, shell scripts, config files β€” any plain text file with code converts cleanly to PDF with BuildPDF. The output is formatted as monospace text, ideal for printing code reviews or archiving configuration snapshots. Note: very long lines (common in generated output or minified code) will word-wrap in the PDF. Break long lines in the source file before converting if you need them to stay on one line.

Log files

Application logs, server logs, and debug traces are natural candidates for TXT-to-PDF conversion β€” especially for bug reports, support tickets, or post-mortems. Use Narrow (5mm) margins to fit more content per page. For very large log files (10,000+ lines), trim to the relevant section before converting to keep the PDF manageable.

Poems, lyrics, and creative writing

Plain text is a common format for writing drafts. When converting poetry or creative prose, BuildPDF respects hard line breaks in the source file β€” a line that ends with Enter in the .txt will end with a line break in the PDF, exactly what you want for verse. Use Wide (20mm) margins for an elegant, book-like appearance.

README and documentation files

Software projects almost always include a README.txt at their root. Converting these to PDF is useful for client handoffs, printed technical documentation, or packaged deliverables. Note: .md (Markdown) files can be dropped into BuildPDF, but Markdown syntax characters (##, **, etc.) will appear literally in the PDF β€” BuildPDF does not render Markdown. For rendered Markdown-to-PDF, use Pandoc or a Markdown editor with export support.

Pro Tips for Better TXT-to-PDF Results

Common Questions

Can I convert a .txt file that contains emoji?

Yes, as long as the file is saved as UTF-8 (which it will be if created on a modern system). Emoji are standard Unicode characters and BuildPDF's PDF engine supports a wide range of Unicode glyphs. Some very recently-added or obscure emoji may not render depending on font coverage, but the vast majority of common emoji will appear correctly.

My text file has tabs for indentation. Will they be preserved?

Tab characters are preserved as whitespace in the PDF output. However, the visual width of a tab stop in the PDF may differ from what you see in your text editor β€” editors default to 4-space or 8-space tab widths while the PDF renderer may use a different value. If precise indentation matters, convert tabs to spaces in your editor before converting (most code editors have a "Convert Indentation" feature).

Will page numbers be added to the PDF?

BuildPDF does not currently add automatic page numbers to TXT conversions. If you need page numbers, consider opening the resulting PDF in LibreOffice Draw or Adobe Acrobat to add headers or footers, or convert the .txt to .docx in a word processor, add page numbers there, and then use BuildPDF's DOCX-to-PDF converter.

Common Issues & How to Fix Them

Characters appear as boxes or question marks

This is almost always an encoding mismatch β€” the file is likely in a non-UTF-8 encoding. Open the file in Notepad++ or VS Code, check the encoding shown in the status bar, and use "Convert to UTF-8" before trying again in BuildPDF. Characters in extended ASCII (Windows-1252) code points 128–255 are the most common culprits.

The PDF has strange line breaks mid-sentence

If lines break at odd places, the source .txt file contains hard line breaks at those positions β€” it was likely written in an editor that inserts a newline at column 80. Fix: open the file in a word processor, use Find & Replace with regular expressions to replace single newlines with spaces (preserving paragraph breaks), then re-save and re-convert.

The converted PDF is many more pages than expected

A large number of pages usually means the file is very long, has extra blank lines, or the font size is set larger than you realise. Check your margin setting β€” Wide (20mm) margins take up space quickly. Switching to Narrow (5mm) margins will fit significantly more text per page. Also confirm you haven't accidentally selected an entire folder of .txt files.

TXT to PDF vs Other Options

It's worth knowing when BuildPDF is the right tool and when to reach for something else:

For raw speed and privacy β€” especially with sensitive log files, config files, or personal notes β€” BuildPDF remains the most practical choice.

Privacy

Your .txt file never leaves your device. Everything is processed locally in your browser. This is especially important for .txt files that might contain passwords, API keys, personal data, or confidential notes β€” none of it is ever sent to a server.

Convert your .txt file to PDF now

Instant, private, free. No sign-up required.

Convert TXT to PDF β†’

Related Guides