WebToolsPlanet
Text Tools

Random Data from Regex

Enter a regular expression and generate random strings that match it — the reverse of regex matching.

Reverse regexTest dataBrowser basedFree

Last updated: May 30, 2026

Client-Side Processing
Input Data Stays on Device
Instant Local Execution

Find this tool useful? Support the project to keep it free!

Buy me a coffee

What 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

1

Type or paste a regular expression (for example [A-Z]{3}-\d{4})

2

Set how many values you want to generate

3

Click Generate to produce matching strings

4

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.

Pattern
[a-z][a-z0-9_]{4,11}
Sample output
m3rcy_owl
kappa_19
q7zelda

How 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

TypeScriptRecursive-descent regex parserWeb randomClient-side processing

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.