To turn a TXT file into Markdown, it is often enough to change its extension from .txt to .md. Markdown is plain text, so a text file is already a valid Markdown document.
Plain text has no headings, bold or tables to recover, and a converter will not invent them. Converting with MD Factory helps in other cases: the file is in an old encoding such as Windows-1251, the TXT files share a folder with PDFs and Word documents, or every file in a library for an AI agent has to be in the same form.
When renaming is enough
Renaming works when the text is in UTF-8 and nothing else needs the file under its old name. The CommonMark specification of Markdown says that any sequence of characters is a valid document.
To see the encoding, open the file in Notepad and look at the bottom-right corner of the status bar. UTF-8 means you can rename the file. Anything else, such as ANSI or UTF-16, has to become UTF-8 first, and the sections below show how. ANSI stands for an older Windows encoding, such as Windows-1251 for Cyrillic or Windows-1252 for Western European languages.
To rename one file, turn on file name extensions in File Explorer: View, then Show, then File name extensions. Then change the end of the name from .txt to .md and confirm when Windows asks about changing the extension. As Microsoft notes, a new extension changes only the name, not the contents.
For many files, open PowerShell in their folder. This command only lists what it would rename:
Get-ChildItem -Filter *.txt | Rename-Item -NewName { $_.BaseName + '.md' } -WhatIf
If the list is right, run the same command without the last part:
Get-ChildItem -Filter *.txt | Rename-Item -NewName { $_.BaseName + '.md' }
To include subfolders, use the same two commands with one more parameter:
Get-ChildItem -Filter *.txt -Recurse | Rename-Item -NewName { $_.BaseName + '.md' } -WhatIf
Get-ChildItem -Filter *.txt -Recurse | Rename-Item -NewName { $_.BaseName + '.md' }
If another program opens these files by their old names, copy them before renaming.
When converting is worth it
| Situation | After renaming | After converting with MD Factory |
|---|---|---|
| The text is in Windows-1251 or another old encoding | The text stays in that encoding; an app that reads the file as UTF-8 shows garbled characters | The text is saved in UTF-8, and the file is marked Needs review so you can check it |
| TXT files share a folder with PDF, Word and other documents | Only the TXT files change; the other documents need another tool | One pass over the folder and its subfolders; every document gets a Markdown file next to it |
| The original files must stay as they are | The TXT file becomes the Markdown file | The TXT file stays unchanged, and the Markdown file appears next to it |
| A script or an AI agent needs every file in the same form | Each file keeps its own encoding and line endings | Every Markdown file has the same encoding and line endings |
For a folder with many formats, see how to batch convert documents to Markdown. To arrange the result for an AI agent, see how to prepare documents for AI agents.
What MD Factory does with a TXT file
Add the TXT files or their folder with Add files or Add folder, or drop them onto the window. Conversion starts at once, and each Markdown file is saved next to its TXT file. MD Factory copies the text as it is: it adds no headings or lists and rewrites nothing.
- Text in UTF-8, or with a byte order mark, is read as is. The file gets Completed status.
- Text in an older encoding is recognized from its content and saved in UTF-8. Such a file always gets Needs review, with the message "The text encoding was inferred. Check special characters."
- If the encoding cannot be determined, the file fails with the message "The text encoding could not be read reliably."
- The Markdown file is always UTF-8 without a byte order mark, with LF line endings.
- Characters that Markdown reads as formatting stay as they are. A line that starts with # and a space becomes a heading in a Markdown viewer, and a word between asterisks becomes italic.
- Only files ending in .txt are converted. Files such as .log or .ini are listed as skipped; rename them to .txt to convert them, or straight to .md.
- A TXT file larger than 64 MB fails with the message "This document exceeds the current processing limits." Split it into smaller files, or rename it instead.
Check files with a guessed encoding
Open each file marked Needs review and look at the characters outside the English alphabet: Cyrillic letters, accented letters, curly quotes and dashes.
Cyrillic text in Windows-1251, KOI8-R or DOS 866 is usually recognized correctly if the file holds at least a sentence.
Western European text in Windows-1252 is the weak spot. MD Factory often takes it for Central European Windows-1250, and some letters change: è becomes č, ñ becomes ń, ã becomes ă.
If such characters are rare in a file, for example a few accented names or curly quotes in English text, they turn into the � sign.
The TXT file itself is not changed, so you can fix it and convert it again. Save the file only when its text looks right: saving garbled text in UTF-8 makes the damage permanent. If the file matters, work on a copy.
- Open the TXT file in Notepad. If the text looks right, choose File, then Save as, set Encoding to UTF-8 and save.
- If the text looks wrong in Notepad too, open the file in Visual Studio Code. Click the encoding in the status bar, choose Reopen with Encoding and pick the right one, for example Western (Windows 1252). Then click the encoding again and save the file in UTF-8.
- In MD Factory, clear the list and add the file again. Or simply rename it to .md: in UTF-8 it no longer needs converting.
MD Factory replaces its earlier result if you have not edited it. If you have, the new result is saved with a number, such as notes (2).md.
Add headings and lists yourself
Plain text does not say which line is a heading, so the structure is up to you. Open the Markdown file in any text editor and type these marks at the start of a line:
| To get | Start the line with |
|---|---|
| A heading | # and a space; ## for a subheading, ### for the level below |
| A bulleted list item | - and a space |
| A numbered list item | 1. and a space |
| A new paragraph | An empty line before it |
A single line break inside a paragraph may show as a space: the CommonMark specification allows either. Where line breaks matter, as in addresses or poems, end each line with a backslash or put an empty line between the lines.
To keep a character from turning into formatting, put a backslash before it: \# at the start of a line shows a plain #. GitHub's guide to basic writing and formatting syntax lists the other marks.
An AI agent can add the structure for you. Ask it to keep the words and to write to a new file:
Add Markdown headings and lists to notes.md.
Do not change, add or remove any words.
Save the result as notes-formatted.md and leave notes.md unchanged.
Compare the two files before you keep the new one. To see the result with its formatting, read how to open an MD file on Windows.