DEV Community

Michael Lip
Michael Lip

Posted on • Originally published at zovo.one

Text Repetition: The Boring Utility That Saves Hours in Testing

I was testing an input field with a 5,000-character limit. I needed exactly 5,001 characters to verify the validation. I also needed exactly 5,000 characters to verify the boundary. And I needed 4,999 to verify the happy path.

I could type "a" 5,001 times. Or I could use a text repeater and be done in 3 seconds.

The obvious use case: testing limits

Every input field has (or should have) a character limit. Every database column has a maximum length. Every API payload has a size constraint. Testing these boundaries requires generating text of precise lengths.

// What you need for testing
"a".repeat(255)    // VARCHAR(255) boundary
"a".repeat(256)    // VARCHAR(255) overflow
"x".repeat(65536)  // TEXT column boundary
Enter fullscreen mode Exit fullscreen mode

In JavaScript, String.prototype.repeat() handles this. But not everyone is testing in a JavaScript context. Sometimes you need to paste a specific amount of text into a web form, a mobile app, a desktop application, or a document.

Less obvious use cases

Load testing. Generating large request bodies to test how your API handles payloads at the size limit. If your API accepts JSON with a description field, you need to test with descriptions at the maximum allowed length.

Email testing. Email subjects have soft limits around 78 characters and hard limits around 998 characters per RFC 2822. Subject lines beyond the soft limit get truncated in most email clients. Testing exactly how they truncate requires generating subjects of specific lengths.

SMS testing. A single SMS is 160 characters (7-bit GSM encoding) or 70 characters (Unicode). Multi-part SMS splits at these boundaries. Testing the concatenation behavior requires messages of exactly 160, 161, 320, and 321 characters.

UI overflow testing. What happens when a user's name is 100 characters long? Does the layout break? Does it truncate with an ellipsis? Does it wrap? You need test data at various lengths to verify.

Performance profiling. Generating strings of specific sizes to measure parsing, indexing, or rendering performance as a function of input size. Is your markdown parser O(n) or O(n^2)? Repeat a pattern at 1KB, 10KB, 100KB, and 1MB to find out.

Beyond simple repetition

A useful text repeater goes beyond just repeating a single character:

Pattern repetition with separator. Repeat "word" 100 times with spaces: word word word... Repeat "item" 50 times with newlines: one item per line. Repeat with commas for CSV test data.

Numbered repetition. Line 1\nLine 2\nLine 3... -- repeating a pattern with an incrementing counter. Essential for generating test data that is identifiable.

Character count targeting. "Give me exactly 500 characters of text" -- repeating a phrase and truncating to hit the exact target, handling the partial repetition at the end cleanly.

Unicode repetition. Repeating emoji, CJK characters, or other multi-byte characters where the byte length differs from the character count. A field might allow 100 characters but only 200 bytes. Testing with multi-byte characters exposes the difference.

The implementation nuance

Repeating a string N times is trivially simple in most languages. But generating repeated text that looks natural enough to paste into a real application requires more thought. A field filled with "aaaaaaa..." is obviously test data. A field filled with "The quick brown fox jumps over the lazy dog. The quick brown fox..." is more realistic and less likely to be flagged by content moderation systems during testing.

I built a text repeater at zovo.one/free-tools/text-repeater that handles all these scenarios: repeat any text or pattern a specified number of times, with configurable separators, optional numbering, exact character count targeting, and clipboard-ready output. It is the simplest tool I have built and one of the most frequently used.

I'm Michael Lip. I build free developer tools at zovo.one. 500+ tools, all private, all free.

Top comments (0)