Back to Free Tools

FREE TOOLS

Regex Literal Escaper

Escape text into a literal JavaScript regex fragment using RegExp.escape rules.

Pasted text, One UTF-8 text file

escaped-pattern.txt, regex-escape-report.json

Browser only

Runs locally in your browser. Your files, pasted content and generated output are not uploaded. Reset clears this tool’s working data.

This tool needs JavaScript. If it does not load, refresh the page and try again.

How to use this tool

  • Paste text or choose one UTF-8 file. The selected file takes precedence, including an empty file.
  • Choose Escape literal text and download the escaped pattern or the complete report.
  • Use the pattern as a literal fragment in a JavaScript RegExp. Reset clears the working input and downloads.

Examples

The text a.b becomes \x61\.b, so the dot matches a literal dot.

Limitations

  • At most 100000 UTF-16 code units and 400000 UTF-8 bytes of input, 5 MiB combined output and 30 seconds of processing.
  • Uses ECMAScript RegExp.escape rules for JavaScript. Output has no delimiter slashes, flags or surrounding quotes; escaping for another programming language or regex engine is not provided.
  • Escapes the complete source as one fragment, preserving spaces, BOM and line endings. Empty input is valid. Invalid UTF-8 and unpaired UTF-16 surrogates are refused.
  • Does not evaluate a user pattern or unescape arbitrary regex syntax. A report contains the complete source and generated pattern. Downstream regex engines may refuse very large patterns even when escaping succeeds.

Related tools

No items found.

More tools for your workflow

Explore the related desktop tool