Skip to content
100% local

Regex simplifier

Rewrite a regular expression as a shorter, functionally equivalent pattern.

Input
Output

Regex simplifier

Paste one regular expression, or a whole list of them, and this tool rewrites each one into a shorter pattern that matches exactly the same text. It is built for cleaning up regex that came from a generator, an old script, or a code review comment that says "this can probably be shorter" — one paste turns a folder of ad-hoc patterns into a tidy, reviewable list.

By default the input is split by line, so every line is treated as its own pattern; switch to splitting by word when your patterns are space-separated instead. Case-sensitive matching and ignore diacritics control how duplicate lines are detected before simplifying, so "Foo" and "foo" — or "cafe" and "café" — can be treated as the same entry or kept apart. Turn on sort results to order the output alphabetically, and set a limit to cap how many simplified patterns come back, which is useful when you pasted more than you meant to review at once.

The simplifier only ever removes what is provably redundant: unnecessary non-capturing groups, quantifiers like {1,1} or {0,1} written out longer than they need to be, character classes with unsorted or overlapping ranges, and alternatives that differ by a single character get folded into one class. Capturing groups, named groups and lookaround are never touched beyond simplifying what is inside them, since removing those would change what a later part of your code can reference. A pattern the tool cannot safely shorten — or cannot parse — is returned exactly as you typed it, and an invalid pattern is left alone rather than guessed at. Export the results as a plain list or as a CSV with the original, the simplified version and the characters saved in each row.

Everything runs locally in your browser — your patterns are never uploaded or logged, so it is safe to paste code straight from a private project. Copy the result, download it as a .txt file, or send the output back into the input to run another pass.

FAQ

Does the simplified regex still match the same text?
Yes. Every rewrite is checked to be an equivalent pattern — redundant groups are removed, character classes are canonicalized and near-identical alternatives are merged, but nothing that would change what the pattern matches is ever touched.
What happens to a pattern the tool can't shorten?
It is returned exactly as you typed it. A line that comes back unchanged means it was already as short as this tool could make it, or it couldn't be parsed as a valid regular expression.
What's the difference between splitting by line and by word?
By line treats each line of the input as one pattern, which fits a list you pasted from a file. By word splits on any whitespace instead, for patterns written on a single line separated by spaces.
Can I export the results as a spreadsheet?
Yes. Switch the output format to CSV to get one row per pattern with the original text, the simplified version and how many characters were saved.
Is my regex uploaded anywhere?
No. Regex simplification runs entirely in your browser — your patterns never leave your device.