Random Data from Regex
Enter a regular expression and generate random strings that match it — the reverse of regex matching.
Last updated: May 30, 2026
Find this tool useful? Support the project to keep it free!
Buy me a coffeeWhat is Random Data from Regex?
Random Data from Regex turns a regular expression into sample strings that satisfy it. Instead of testing whether text matches a pattern, it works backwards: it reads the pattern and produces random values that the pattern would accept. This is sometimes called a "xeger" (reverse regex) generator.
It is ideal for creating realistic test data — usernames, IDs, phone numbers, hex colours, IP addresses — from a single pattern. Everything runs locally in your browser.
How to Use Random Data from Regex
Type or paste a regular expression (for example [A-Z]{3}-\d{4})
Set how many values you want to generate
Click Generate to produce matching strings
Copy all the values for use in tests or seed data
Common Use Cases
- Creating test data that matches a specific format or validation rule.
- Generating fake usernames, IDs, SKUs, or codes from a pattern.
- Producing sample phone numbers, IPs, or hex colours for fixtures.
- Seeding a database or form with values that pass regex validation.
Example Input and Output
Generate usernames from a pattern: a letter followed by 4–11 letters, digits, or underscores.
[a-z][a-z0-9_]{4,11}m3rcy_owl
kappa_19
q7zeldaHow This Tool Works
The tool parses the regular expression into a small syntax tree, then walks it, picking random characters from each class and random counts for each quantifier, to build strings the pattern accepts.
Technical Stack
Bounded output
Use explicit ranges like {2,5} for predictable lengths; open repeats are capped to keep results finite.
Privacy
The pattern and all generated values stay in your browser — nothing is sent to a server.
Frequently Asked Questions
What regex features are supported?
Literals, character classes ([a-z], [^0-9]), shorthands (\d \w \s), groups, alternation (|), and quantifiers (*, +, ?, {n}, {n,m}). Lookarounds and backreferences are not supported.
How are open-ended repeats handled?
Unbounded quantifiers like * , + and {n,} are capped so the output stays a finite, reasonable length.
Are the results guaranteed to match?
Yes — for the supported feature set, every generated string is built to satisfy the pattern.
What about anchors like ^ and $?
They are ignored, since the whole generated string already corresponds to the pattern.
Is my pattern uploaded?
No. Parsing and generation run entirely in your browser.
Related Tools
Regex Visualizer
Visualize regular expressions as interactive railroad diagrams — understand complex patterns with a clear SVG flowchart, live match testing, and flag explanations.
Random Test Data Generator
Generate realistic placeholder data (users, addresses, UUIDs) in JSON or CSV for testing APIs and databases.
List Randomizer
Shuffle any list, pick N random winners, or run a fair lottery using the Fisher-Yates algorithm.
UUID Generator
Generate random UUID v4 identifiers instantly — single or bulk, with format options.
Regex Tester
Test and debug regular expressions with live match highlighting, capture group display, and flag explanations — using JavaScript's native RegExp engine.
Color Picker from Image
Extract exact Hex, RGB, and HSL color codes from any image using a precision eyedropper tool.

