Categories

Text File Replacer

Find and replace text in files with support for regex, multiple patterns, and backup creation

Click to upload file or drag and drop file here

Maximum file size: 10MB

Key Facts

Category
Utilities
Input Types
file, text, select, checkbox
Output Type
file
Sample Coverage
4
API Ready
Yes

Overview

The Text File Replacer is a powerful utility designed to efficiently find and update specific strings or patterns within your text files, supporting advanced features like regular expressions and automated backups.

When to Use

  • Updating outdated terminology or variables across large configuration files.
  • Cleaning up formatting or removing unwanted characters from raw data exports.
  • Standardizing naming conventions in code or documentation files before deployment.

How It Works

  • Upload your target file and specify the text or regex pattern you wish to locate.
  • Enter the replacement text and select your preferred replacement scope, such as all occurrences or per-line updates.
  • Enable optional settings like case sensitivity or whole-word matching to refine your search results.
  • Choose to create a backup file for safety, then execute the replacement or run a preview to verify changes.

Use Cases

Bulk updating environment variables in configuration files.
Refactoring code by renaming functions or classes across multiple files.
Sanitizing log files by removing sensitive data using regex patterns.

Examples

1. Updating API Endpoints

Software Developer
Background
A project migration requires updating an old API base URL across several configuration files.
Problem
Manually opening each file to find and replace the URL is error-prone and slow.
How to Use
Upload the config file, enter the old URL in 'Find Text', the new URL in 'Replace Text', and select 'Replace All'.
Example Config
findText: 'api.v1.example.com', replaceText: 'api.v2.example.com', replaceType: 'all'
Outcome
All instances of the old API endpoint are updated to the new version, with a backup created automatically.

2. Cleaning Log Data

Data Analyst
Background
A raw log file contains timestamps that need to be reformatted for a database import.
Problem
The date format is inconsistent and requires regex to identify and reorder the date components.
How to Use
Enable 'Use Regular Expression', input the regex pattern for the date, and define the replacement format.
Example Config
regex: true, findText: '(\d{2})/(\d{2})/(\d{4})', replaceText: '$3-$1-$2'
Outcome
The log file is updated to the ISO date format, making it ready for seamless database ingestion.

Try with Samples

text, regex, file

Related Hubs

FAQ

Can I use regular expressions for complex patterns?

Yes, simply enable the 'Use Regular Expression' checkbox to perform advanced pattern matching.

Is it possible to see changes before modifying the file?

Yes, select the 'Preview Only' option to view the proposed changes without altering the original file.

Does the tool automatically save a copy of my file?

Yes, the 'Create Backup File' option is enabled by default to ensure you have a restore point.

Can I replace only the first occurrence of a word?

Yes, you can set the 'Replace Type' to 'First Occurrence Only' in the configuration settings.

What output formats are available for the report?

You can generate reports in detailed, summary, CSV, or JSON formats to track your changes.

API Documentation

Request Endpoint

POST /en/api/tools/text-file-replacer

Request Parameters

Parameter Name Type Required Description
filePath file (Upload required) Yes -
findText text Yes -
replaceText text Yes -
replaceType select No -
caseSensitive checkbox No -
wholeWord checkbox No -
regex checkbox No -
createBackup checkbox No -
previewOnly checkbox No -
outputFormat select No -

File type parameters need to be uploaded first via POST /upload/text-file-replacer to get filePath, then pass filePath to the corresponding file field.

Response Format

{
  "filePath": "/public/processing/randomid.ext",
  "fileName": "output.ext",
  "contentType": "application/octet-stream",
  "size": 1024,
  "metadata": {
    "key": "value"
  },
  "error": "Error message (optional)",
  "message": "Notification message (optional)"
}
File: File

AI MCP Documentation

Add this tool to your MCP server configuration:

{
  "mcpServers": {
    "elysiatools-text-file-replacer": {
      "name": "text-file-replacer",
      "description": "Find and replace text in files with support for regex, multiple patterns, and backup creation",
      "baseUrl": "https://elysiatools.com/mcp/sse?toolId=text-file-replacer",
      "command": "",
      "args": [],
      "env": {},
      "isActive": true,
      "type": "sse"
    }
  }
}

You can chain multiple tools, e.g.: `https://elysiatools.com/mcp/sse?toolId=png-to-webp,jpg-to-webp,gif-to-webp`, max 20 tools.

Supports URL file links or Base64 encoding for file parameters.

If you encounter any issues, please contact us at [email protected]