Reading Files
Module: Core Features | Lesson: 2 of 7 | Time: ~10 minutes
What You Will Learn
- How to ask Claude to read any file on your computer
- What the Read tool looks like when Claude uses it
- How to read specific parts of large files
- How to read multiple files at once
- That Claude can also read images and PDFs
Prerequisites
- Completed Chatting Effectively
- Claude Code installed and running in your terminal
Why This Matters
Before Claude can help you with any file, it needs to see what is inside that file. Claude does not automatically read every file on your computer. You need to tell it which files to look at. The Read tool is how Claude opens and reads file contents, and it is one of the most frequently used tools in every Claude Code session.
Asking Claude to Read a File
Reading a file is as simple as asking. You can phrase it in many natural ways:
> Read the file config.json
> What's in package.json?
> Show me the contents of notes.txt
> Open index.html and tell me what it does
> Look at the README.md file
All of these will cause Claude to use the Read tool to open the file and display its contents.
Claude understands natural language. You do not need to memorize a specific command format. Just mention the filename and that you want to see it, and Claude will figure out the rest.
What the Read Tool Looks Like
When Claude reads a file, you will see something like this in your terminal:
─ Read file: notes.txt
Here are the contents of notes.txt:
1 Meeting notes from Monday
2 - Discussed project timeline
3 - Assigned tasks to team members
4 - Next meeting: Friday at 2pm
Let's break down what you see:
- The tool indicator (
Read file: notes.txt) -- this shows you which tool Claude used and on which file - The file contents -- Claude displays the text with line numbers on the left side
- Claude's explanation -- after showing the file, Claude usually summarizes or explains what it found
The numbers on the left (1, 2, 3, 4) are line numbers. They are not part of the file itself. Claude adds them so you can refer to specific lines, like "change line 3" or "what does line 12 mean?"
Reading Specific Parts of Large Files
Some files are very long, with hundreds or thousands of lines. You do not always need to see the entire file. You can ask Claude to read just the parts you care about:
> Read the first 20 lines of server.js
> Show me lines 50 through 75 of data.csv
> Read the end of the log file error.log
> What's at the top of index.html?
Claude will read only the section you asked for, which keeps the output manageable and focused.
- Log files: These can be thousands of lines long. Ask for "the last 50 lines" to see recent entries.
- Data files (CSV, JSON): Ask for "the first 10 lines" to understand the format without seeing all the data.
- Long code files: Ask for "the function called handleClick" or "lines 100 to 150" instead of the whole file.
Reading Multiple Files
You can ask Claude to read several files in one request:
> Read both index.html and styles.css
> Show me the contents of package.json, README.md, and .gitignore
> Read all three config files in the settings folder
Claude will read each file and show you the contents one after another. This is useful when you want to understand how files relate to each other, for example, seeing both an HTML file and its CSS stylesheet together.
Claude Can Read More Than Text Files
The Read tool is not limited to plain text. Claude can also handle:
Images
> Read the file logo.png
> What's in screenshot.jpg?
> Look at the diagram in architecture.png and describe what it shows
Claude will view the image and describe what it sees. This is helpful for understanding screenshots, diagrams, or checking that an image looks correct.
PDF Files
> Read the document report.pdf
> What does the PDF manual.pdf say about installation?
> Read pages 1 through 5 of the user-guide.pdf
For large PDFs, ask Claude to read specific pages rather than the entire document.
Other File Types
Claude can read virtually any text-based file format:
- Code files:
.py,.js,.html,.css,.java,.cpp, and many more - Configuration files:
.json,.yaml,.toml,.xml,.ini,.env - Documentation:
.md,.txt,.rst - Data files:
.csv,.tsv
Claude reads files from your local computer only. It cannot read files that:
- Are on a different computer or network drive (unless it is mapped as a local drive)
- Require special software to open (like
.docxWord documents or.xlsxExcel files -- though it can sometimes extract text from these) - Are encrypted or password-protected
What Happens Behind the Scenes
When you ask Claude to read a file, here is what happens:
- You type your request ("Read config.json")
- Claude decides to use the Read tool and specifies the file path
- The tool opens the file on your computer and sends the contents back to Claude
- Claude displays the contents and provides any explanation you asked for
This all happens in a second or two. You do not need to do anything special; just ask, and Claude handles the rest.
Common Questions
Q: Can Claude read files outside my current folder? Yes, but you need to provide the full path. For example: "Read the file C:\Users\MyName\Documents\notes.txt". By default, Claude looks in the folder where you launched it.
Q: What if I ask Claude to read a file that does not exist? Claude will tell you the file was not found. This is not an error on your part; it just means the filename or path might be slightly different. Double-check the spelling and location.
Q: Does Claude remember files it has already read? Yes, within the same session. If Claude read a file earlier in your conversation, it remembers the contents. You do not need to ask it to read the same file again unless the file has changed since then.
Try It Yourself
Follow these steps to practice using the Read tool:
Step 1: Create a Text File Manually
Open Notepad (press Win + R, type notepad, press Enter) and type the following:
My Favorite Movies
1. The Shawshank Redemption
2. The Dark Knight
3. Inception
4. Interstellar
5. The Matrix
Save it as movies.txt in a folder you can easily find (like your Desktop or Documents folder).
Step 2: Start Claude Code in That Folder
Open your terminal and navigate to the folder where you saved the file:
cd C:\Users\YourName\Desktop
claude
Step 3: Ask Claude to Read Your File
> Read the file movies.txt
You should see Claude display the contents of your file with line numbers.
Step 4: Ask About the Contents
> How many movies are in that list?
> Which movie is listed third?
Notice that Claude can answer questions about the file after reading it, without needing to read it again.
Step 5: Try Reading a Specific Part
> Show me just the first 3 lines of movies.txt
If you can see your file's contents displayed with line numbers, and Claude correctly answers questions about it, you have successfully used the Read tool.
What You Learned
- Ask naturally: Just mention the filename and Claude will read it for you
- The Read tool: Claude's built-in tool for opening and displaying file contents
- Line numbers: Displayed on the left for easy reference, but not part of the actual file
- Partial reads: Ask for specific lines or sections of large files
- Multiple files: Read several files in a single request
- Beyond text: Claude can also read images and PDFs
- Session memory: Claude remembers files it has already read during the current session
How was this lesson? Take 2 minutes to share your feedback — it helps us make the tutorials better for everyone.