textswap

Batch text replacement powered by dictionaries. Replace keys with values or values with keys across entire directories.

Python 3.9+ pip install Bidirectional GPL-3.0
pip install textswap

Features

🔁

Bidirectional Replacement

Replace keys with values or values with keys. Perfect for encoding/decoding or reversible transformations.

📚

Multiple Dictionaries

Define multiple replacement dictionaries in one config file and switch between them easily.

🚫

Smart Ignore Patterns

Skip files by extension, prefix, or entire directories. Never accidentally modify binaries or dependencies.

📁

Batch Processing

Process entire directories at once. Recursively replace text across all matching files.

⚙️

JSON Configuration

Simple JSON config file for dictionaries and ignore patterns. Easy to version control.

🎯

Auto-Select Dictionary

If only one dictionary exists, it's automatically selected. No extra prompts needed.

Quick Start

config.json
{
  "dictionaries": {
    "obfuscate": {
      "password": "p4ssw0rd",
      "admin": "4dm1n",
      "secret": "s3cr3t"
    }
  },
  "ignore_extensions": [".exe", ".dll", ".bin"],
  "ignore_directories": ["node_modules", "venv", ".git"],
  "ignore_file_prefixes": [".", "_"]
}
Terminal
# Interactive mode
$ textswap

# With options
$ textswap -f ./src -d 1 -c config.json

# Dry run (preview changes)
$ textswap -f ./src -d 1 --dry-run