Regex Benchmark & ReDoS Simulator
Time a JavaScript regular expression against your own text, see operations per second, and run a scaling test with the input repeated up to 16 times to reveal polynomial or exponential backtracking.
Use the tool
Why this tool exists
A regex that works on a small test string can freeze a server when it meets a long or hostile input. Nested quantifiers like (a+)+ make the engine try an exploding number of paths, which is the basis of regular expression denial of service. You usually find out in production.
This tool measures instead of guessing. It runs your pattern repeatedly and reports operations per second, then repeats the text at growing sizes and shows how time grows. A linear curve is fine; a steep one is a warning. A static check also flags nested quantifiers. Be careful: a truly catastrophic pattern can freeze the tab, so start with short input. It uses JavaScript's own engine, so results may differ in other languages.
How to use it
- Enter your regular expression and its flags.
- Paste a sample text, and keep it short for the first run.
- Set the number of iterations and run the benchmark.
- Read the speed and the scaling results, and rewrite the pattern if time grows steeply.
Frequently asked questions
Why did my tab freeze?
The pattern was catastrophic for that input. Backtracking can grow exponentially, and the page cannot interrupt a running regex. Close or reload the tab and retry with much shorter text or a safer pattern.
Do results apply to other languages?
Only partly. This uses the JavaScript engine in your browser. Engines such as RE2 avoid backtracking, while PCRE, Python and Java can behave differently. Test in your own runtime for critical code.
How can I make a slow regex safer?
Remove nested quantifiers, make alternatives mutually exclusive, anchor the pattern where possible and limit input length. Atomic groups or possessive quantifiers help in engines that support them, but JavaScript does not have them.