Overview
Introduction
Letter transpositions, typing "form" instead of "from", are one of the most common typing mistakes, and being able to generate realistic-looking versions of them is useful for testing typo tolerance or building example datasets.
This tool runs entirely client-side, so nothing you paste is ever uploaded to a server.
What Is Letter Swapper?
A letter swapper that scans each word of four or more letters and, based on a probability you set, randomly swaps two adjacent letters inside the word while keeping the first and last letters fixed.
It's built on the same principle behind typoglycemia demonstrations: readers can often still recognize a word even when its interior letters are scrambled, as long as the first and last letters stay put.
How Letter Swapper Works
The tool splits the input into whitespace-separated tokens, and for each purely alphabetic token of four or more letters, rolls the configured probability to decide whether to modify it.
When a word is selected, it picks a random adjacent pair among the interior letters and swaps them, then rejoins all tokens with their original spacing preserved.
When To Use Letter Swapper
Use it to generate realistic typo variants for testing a spell checker, fuzz-testing search or autocomplete, or creating deliberately imperfect sample text for a proofreading exercise.
It's a fast way to get varied, plausible-looking typos without hand-editing text or writing a one-off script.
Often used alongside Word Swapper, Random Letter Adder and Case Converter.
Features
Advantages
- Keeps the first and last letters fixed, which is how real transposition typos usually read.
- Adjustable probability controls how heavily the text is affected.
- Only words of four or more letters are eligible, so short words stay intact and the result still scans as ordinary prose with typos in it.
Limitations
- Only affects purely alphabetic words of four or more letters; numbers and punctuation-attached tokens are left unchanged.
- Uses randomness, so results aren't reproducible between runs.
Examples
Best Practices & Notes
Best Practices
- Set the probability lower for subtle, occasional typos and higher for heavily garbled test text.
- Run the tool multiple times if you need several distinct typo variants of the same source text.
- Keep the original alongside the output when generating test data, since the swap is random and cannot be reversed to recover the source.
Developer Notes
Each eligible word picks a random offset `i` in the range `[1, length - 3]` and swaps `chars[i]` with `chars[i + 1]`, which guarantees the swap always stays strictly between the first and last character regardless of word length.
Letter Swapper Use Cases
- Generating realistic typo test cases for a spell checker or autocomplete feature
- Fuzz-testing text input handling with plausible near-word data
- Creating imperfect sample text for a proofreading or editing exercise
Common Mistakes
- Expecting every word to be modified; only words of four or more letters are eligible, and the probability may skip some of those.
- Assuming the first or last letter of a word can change; they never do.
Tips
- Combine with a random letter adder for text that mixes both transposition and insertion typos.
- A four-letter word has only one possible swap position, so whenever one is selected it always garbles in exactly the same way.