The fastest way to see what's inside a file without opening an process
You can display the contents of a text file directly in Command Prompt using the type command. This is the simplest method when you need to quickly peek at what a file contains — no process launch, no waiting for a program to load. The command works on any Windows machine and takes one line to run.
The basic syntax is straightforward: type the word type, then a space, then the full path to your file. Command Prompt will print the entire contents to the screen. This works for text files, configuration files, log files, and any document saved as plain text.
Key Takeaways
- The type command displays file contents directly in Command Prompt without opening any process.
- You must navigate to the file's folder first using cd, or provide the complete file path including the drive letter and all folder names.
- For large files that scroll off the screen, use type filename | more to view one page at a time and press spacebar to advance.
- The type command works only on text-based files; it will display garbage characters if you try to view binary files like images or executables.
Opening Command Prompt and navigating to your file
Start by opening Command Prompt. Press the Windows key, type cmd, and press Enter. A black window will appear with a cursor blinking next to a drive letter and colon — usually C:\ or C:\Users\YourName.
Navigate to the folder containing your file using the cd command, which stands for "change directory". Type cd, then a space, then the folder path. For example, if your file is in Documents, type cd Documents and press Enter. If your file is nested deeper — say, in Documents\Projects\Reports — type the full path: cd Documents\Projects\Reports.
Once you are in the correct folder, you can verify the file is there by typing dir and pressing Enter. This lists all files and folders in your current location. Look for your filename in the list to confirm you are in the right place.
Displaying file contents with the type command
Now that you are in the folder containing your file, type type filename.txt (replace filename.txt with your actual filename) and press Enter. The entire contents of the file will print to the screen when ready.
If you do not know the exact filename, type dir again to see the precise spelling and extension. Filenames are case-insensitive in Command Prompt, so type MyFile.txt and type myfile.txt will both work.
The type command works on any text file: .txt files, .csv files, .log files, .ini configuration files, .bat batch files, and .xml files. It will not work properly on binary files like .exe, .jpg, .png, or .docx — those will display as random characters and symbols.
Viewing large files one page at a time
If your file is long and scrolls past the top of the Command Prompt window, you will lose the beginning. Use the more command to pause the display after each screen. Type type filename.txt | more and press Enter. The pipe symbol (|) sends the output to the more command, which breaks it into pages.
When you see -- More -- at the bottom of the window, press the spacebar to view the next page. Press q to quit and return to the Command Prompt.
An alternative is more filename.txt, which does the same thing without the type command. Both methods work equally well.
Using the full file path if you do not want to navigate folders
If navigating folders feels cumbersome, you can provide the complete path directly. Type type C:\Users\YourName\Documents\filename.txt and press Enter, replacing the path with your actual file location. This displays the file contents without changing your current folder.
To find the full path of a file, open File Explorer, right-click the file, and select Properties. The location field shows the folder path. Copy it, then paste it into Command Prompt after the type command.
Searching for text within a file
If your file is very long and you need to find a specific word or phrase, use the findstr command. Type findstr "search term" filename.txt and press Enter. Command Prompt will display only the lines containing your search term.
For example, findstr "error" logfile.txt will show every line in logfile.txt that contains the word "error". This is much faster than scrolling through a large file manually. The search term is case-insensitive by default.
Troubleshooting common issues
If you see "The system cannot find the file specified", you are either in the wrong folder or the filename is spelled incorrectly. Type dir to list all files in your current location and verify the exact spelling and extension.
If you see random characters and symbols instead of readable text, you are trying to view a binary file (like an image or executable). The type command only works on text files. Use File Explorer to open the file with the correct process instead.
If the file path contains spaces, wrap the entire path in quotation marks. For example: type "C:\Users\My Name\My Documents\filename.txt". Without the quotes, Command Prompt will interpret the space as the end of the path.
Frequently Asked Questions
Can I view a file without knowing its exact name?
Type dir to list all files in the current folder. Look for the filename you need, then use the exact spelling and extension with the type command. You can also use wildcards: type *.txt will display all .txt files in the folder, one after another.
What if the file is on a different drive, like D: or E:?
Type the drive letter followed by a colon, like D:, and press Enter to switch drives. Then use cd to navigate to the folder, just as you would on the C: drive. Alternatively, provide the full path including the drive letter: type D:\folder\filename.txt.
Can I save the file contents to a new file instead of displaying them?
Yes. Type type filename.txt > newfile.txt and press Enter. This creates a copy of the file contents in a new file called newfile.txt in the same folder. The > symbol redirects the output to a file instead of the screen.
Why does the output look jumbled or cut off?
If lines are wrapping awkwardly, your Command Prompt window may be too narrow. Drag the right edge of the window to make it wider. If text is scrolling too fast, use the more command to pause between pages: type filename.txt | more.
Is there a way to view only the first or last few lines of a file?
Command Prompt does not have a built-in command for this, but you can use findstr with line numbers: findstr /N "." filename.txt | more. This shows each line with its line number and pauses after each screen. For just the first 10 lines, there is no straightforward one-line method in standard Command Prompt.