How to create a text file

Updated: 09/03/2019 by Computer Hope

You can create a text file on your computer with a text editor. An example of a text editor is Notepad, which is included with Microsoft Windows.

Note

When we refer to a "text file" we mean a plain text file without any text formatting (e.g., bold), images, different fonts, font sizes, etc. If create a more rich document with any of these features see: How to create a document.

Tip

The below recommendations are for programs included with an operating system. You can also download and install a more powerful and free text editor such as Notepad++ to create, view, and edit text files.

Open and use Notepad

The easiest way to create a text file in Windows is to open up the Notepad program on your computer. The Notepad is a text editor included with Microsoft Windows.

Tip

A text file is considered a plaintext file and Notepad is only capable of creating and editing plaintext files. Notepad saves any text file with a .txt file extension, which means no special formatting or fonts can be used.

The Windows Notepad program can be opened using a method mentioned below.

  1. Click Start.
  2. In the Run or Search box, type Notepad and press Enter.

Or

  1. Click Start.
  2. Open All Programs, Accessories, then click the Notepad shortcut.

Save the file as a text file

You can also create a text file using any other word processing program, like Microsoft Word or WordPad. When saving the file, change the file name or file type to Plain Text to save it as a text file. In many of these programs, you can save the file as a Rich Text Format.

Save As option

After the file is created and saved, it can also be edited using Notepad or another word processing program.

Create a new text file from the desktop

Another way to create a text file is to right-click an empty area on the desktop, and in the pop-up menu, select New, and then Text Document.

Creating a text file this way opens your default text editor with a blank text file on your desktop. You can change the name of the file to anything you want. You can edit the file in the Notepad program or any other word processing program, like Microsoft Word.

Tip

These same steps can be used in any other location on your computer, for example, another folder.

Create a text file from the Windows command line

While in the Windows command line, you also can create a new text file in the current directory. With earlier versions of Windows, a new file of any type, including text files, could be created using the edit command line command. Later versions of Windows removed the ability to use the edit command for this purpose. Instead, you can use the echo command at the Windows command line to create an empty text file in the current directory. An example of using this shown below.

echo.>myfile.txt

In the example above, you are using the echo command to create a file named "myfile.txt" in the current directory. Note that there are no spaces between echo, the period, the greater-than sign (>), and the file name.

Another option for creating a text file from the command line is with the start command, as shown in the example below.

start notepad myfile.txt

In this example, you are using the start command to open Notepad with the file "myfile.txt". Assuming this file does not exist, it would be created and saved in your current directory. If the file did exist, you would be editing that file.

Create a text file from within a Linux shell

pico command

Several commands can create a text file in a Linux shell. One easy-to-use text editor is pico. You can use it like this:

pico myfile.txt

After entering the command above, the editor opens and lets you create a text file. When done, press Ctrl+X to exit the file. When prompted to save the file, to keep the file, press "Y" for yes.

Tip

The .txt file extension is not required in Linux. It is a file extension most commonly found and used with Windows. If you do not need the file to open in Windows, you can have no file extension or rename it to whatever you want.