> ## Documentation Index
> Fetch the complete documentation index at: https://desktopcommander.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Read File

> View the contents of any file on your system with flexible reading options

# read\_file

The `read_file` tool allows Claude to view the contents of files on your system. It's one of the most commonly used tools and supports both local files and URLs.

## What it does

Reads and displays file contents with smart features:

* View entire files or specific sections
* Read from the beginning, middle, or end of files
* Handle both text and image files
* Work with files of any size efficiently
* Support for URLs when needed

## How it works

Simply ask Claude to read any file:

```
"Can you read the README.md file in my project?"
"Show me the last 20 lines of the error log"
"Read the config.json file and explain the settings"
```

Claude will automatically use the read\_file tool to access and display the content.

## Key Features

> **Partial Reading**
>
> Read specific sections of large files without loading everything into memory

> **Smart Navigation**
>
> Use positive offsets to start from a specific line, or negative offsets to read from the end

> **Image Support**
>
> View images directly - supports PNG, JPEG, GIF, and WebP formats

> **Performance Optimized**
>
> Efficient handling of large files with intelligent reading strategies

## Reading Options

### Read Entire File

```
"Read the entire package.json file"
```

Shows the complete file contents from beginning to end.

### Read Specific Range

```
"Show me lines 50-100 of the data.csv file"
```

Reads only the specified line range, perfect for large files.

### Read from End (Tail)

```
"Show me the last 50 lines of the application.log"
```

Reads from the end of the file, like the `tail` command.

### Read with Offset

```
"Skip the first 25 lines and show me the next 10 lines"
```

Start reading from a specific position in the file.

## Practical Examples

### Log File Analysis

```
"Read the last 100 lines of /var/log/application.log and look for any errors"
```

### Code Review

```
"Read the main.py file and explain what this script does"
```

### Configuration Check

```
"Read my .env file and verify all required environment variables are set"
```

### Data File Preview

```
"Show me the first 10 lines of sales_data.csv to understand the structure"
```

### Documentation Review

```
"Read the API documentation file and summarize the authentication requirements"
```

## Technical Details

The read\_file tool includes several advanced features:

### Automatic Path Handling

* Converts relative paths to absolute paths for reliability
* Works with different path formats (Windows backslashes, Unix forward slashes)
* Handles tilde expansion (`~/Documents/file.txt`)

### Intelligent Reading

* **Small files**: Read entirely with fast streaming
* **Large files with offset**: Use byte estimation for efficiency
* **Large files from end**: Reverse reading for tail operations
* **Image files**: Return as viewable images rather than binary data

### Configurable Limits

* Default line limit: 500 lines (configurable)
* Customizable via the `fileReadLineLimit` setting
* Prevents accidental loading of extremely large files

## Security Considerations

> [!WARNING]
>
> The read\_file tool can only access files within allowed directories. By default, this is usually your home directory and common work folders.

### Directory Restrictions

* Configure allowed directories through system settings
* Prevents access to sensitive system files
* You can expand or restrict access as needed

### File Type Safety

* Handles binary files safely (shows as images when appropriate)
* Prevents loading of extremely large files accidentally
* Smart detection of file types and content

## Common Use Cases

**Development**

* Review source code files
* Check configuration files
* Examine log files for debugging
* Read documentation and README files
* Inspect data files and formats

**Data Analysis**

* Preview CSV files before processing
* Check JSON structure and format
* Examine sample data for patterns
* Review exported data files
* Validate file formats and encoding

**System Administration**

* Check configuration files
* Review system logs
* Examine script files
* Monitor file changes
* Verify backup contents

**Content Management**

* Review document contents
* Check file formats and structure
* Verify exported content
* Examine templates and layouts
* Preview generated files

## Tips for Effective Use

> [!TIP]
>
> When working with large files, start by reading a small section first to understand the structure before reading more.

> [!TIP]
>
> Ask Claude to show line numbers when reading code files for easier reference during discussions.

> [!TIP]
>
> Use read\_file together with search tools to first find files, then examine their contents.

> [!TIP]
>
> For image files, read\_file will show you the actual image - great for quick previews without opening external applications.

## Related Tools

* [write\_file](https://desktopcommander.mintlify.site/tools/file-operations/write-file.md) - Create or modify file contents
* [edit\_block](https://desktopcommander.mintlify.site/tools/file-operations/edit-block.md) - Make targeted changes to files
* [search\_code](https://desktopcommander.mintlify.site/tools/search/search-code.md) - Search for content within files
* [get\_file\_info](https://desktopcommander.mintlify.site/tools/file-operations/get-file-info.md) - Get file metadata and properties


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.