Mass URL-Encoding a File

Fuzzing payloads frequently contain characters that are reserved or unsafe in URLs — spaces, &, =, %, non-ASCII bytes — and must be percent-encoded before use, or a single wordlist entry can silently break the request or be mis-parsed by the target. Encoding a whole wordlist line-by-line is the fix, and the result drops straight into tools like turbo-intruder, wfuzz, or shell loops.

Python one-liner script

Python’s urllib.parse.quote handles UTF-8 and pre-existing % characters correctly — this pattern comes from the canonical Stack Overflow answer on percent-encoding URL parameters:

#!/usr/bin/env python3
 
import urllib.parse
 
for line in open('/path/to/file.txt'):
    print(urllib.parse.quote(line.encode('utf8'), safe=''))
  • line.encode('utf8') — encode to UTF-8 bytes first, so non-ASCII characters become their multi-byte percent-encoded form (e.g. é%C3%A9)
  • safe='' — encode everything non-alphanumeric, including characters quote would otherwise leave alone (like /) — the right choice when whole lines are payload values
  • Output goes to STDOUT; redirect to a new file (> encoded.txt)

Note: each line retains its trailing newline, which gets encoded as %0A — usually harmless in fuzzing payloads, but strip with line.rstrip('\n') first if it matters.

See also

Sources