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.

