Skip to content
Flavor
ECMAScript
Deadline
500 ms
Runtime
Browser

Escape arbitrary text as one literal regex pattern

Convert user text into a pattern fragment that matches the text literally instead of interpreting regex syntax.

Local processingNo sign-upKillable worker

Input

Enter text that should become one literal ECMAScript pattern fragment.

Local

Escaped pattern fragment

Submit the example or replace it with your own values. User matching runs only in a disposable browser worker.

What this tool proves

Explicit ECMAScript behavior

Safe escaping is broader than adding a backslash before punctuation. ECMAScript escapes a leading ASCII letter or digit, several punctuators, whitespace, line breaks, syntax characters, and lone surrogates in different ways so the fragment can be concatenated safely.

Literal escaping neutralizes syntax without adding delimiters

Safe escaping is broader than adding a backslash before punctuation. ECMAScript escapes a leading ASCII letter or digit, several punctuators, whitespace, line breaks, syntax characters, and lone surrogates in different ways so the fragment can be concatenated safely.

The output follows the RegExp.escape algorithm shape, including hexadecimal escaping for a leading alphanumeric and punctuators such as hyphen. It does not add / delimiters or flags, leaving integration choices to the caller.

Bounded execution protects the page without hiding risk

Any operation that runs a user pattern is isolated in a disposable Web Worker. Tool Swim terminates that worker after 500 ms, caps patterns at 4 KiB and text at 256 KiB, and never runs user matching on the interface thread.

Pattern, flags, text, replacement, matches, and explanations stay in the current browser tab. The public tool makes no developer API request, stores no preset, and works without an account or telemetry.

Primary references

Questions and answers

Related Regex tools