Format Regex
Regex is the only code we routinely ship with zero formatting. Format Regex fixes that.
A pattern starts as a quick validation rule. Then someone adds a branch, a named group, an exception, a comment. It still works, but now it is a 400-character string and code review has quietly given up on it. Format Regex takes any free-spacing pattern and lays it out deterministically, so the structure is visible instead of implied.
See it
Before:
(?:[a-z0-9!#$%&'*+\x2f=?^_`\x7b-\x7d~\x2d]+(?:\.[a-z0-9!#$%&'*+\x2f=?^_`\x7b-\x7d~\x2d]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9\x2d]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9\x2d]*[a-z0-9])?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9\x2d]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])
After:
(?:
[a-z0-9!#$%&'*+\x2f=?^_`\x7b-\x7d~\x2d]+
(?: \. [a-z0-9!#$%&'*+\x2f=?^_`\x7b-\x7d~\x2d]+ )*
| "
(?:
[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]
| \\ [\x01-\x09\x0b\x0c\x0e-\x7f]
)*
"
)
@
(?:
(?: [a-z0-9] (?: [a-z0-9\x2d]* [a-z0-9] )? \. )+ [a-z0-9]
(?: [a-z0-9\x2d]* [a-z0-9] )?
| \[
(?:
(?:
(
2 ( 5[0-5] | [0-4][0-9] )
| 1[0-9][0-9]
| [1-9]? [0-9]
)
)
\.
){3}
(?:
(
2 ( 5[0-5] | [0-4][0-9] )
| 1[0-9][0-9]
| [1-9]? [0-9]
)
| [a-z0-9\x2d]* [a-z0-9]:
(?:
[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]
| \\ [\x01-\x09\x0b\x0c\x0e-\x7f]
)+
)
\]
)
Same pattern. Same behavior. One of them you can review.
Why it's worth paying for
- Reviewable diffs: deterministic output means a one-character logic change shows up as a one-line diff, not a reformatted blob.
- Trustworthy patterns: when groups line up and alternatives stack, a reviewer can reason about behavior instead of counting parentheses.
- No style debates: same input, same output, every time. There is nothing left to argue about in the PR.
- Portable: clean a pattern once before copying it between languages, services, or documentation.
It matters most exactly where regex is expensive to get wrong: in production code, shared across a team, reviewed for correctness or security, or revisited months later by someone who is not you.
Deterministic by design
The formatter is not trying to make your regex look clever. It makes the structure obvious and does the same thing every time. That repeatability is the feature: predictable output is what makes formatting safe to run in a real workflow instead of a one-off cleanup.
Where it fits
Advanced Benchmarking answers how does this regex perform? Format Regex answers can a human actually read it? Both are part of the regex101 Pro direction: a serious IDE for the people who build, inspect, tune, and maintain patterns long after the first commit.