Regex Literal Escape

Paste any text and get it back escaped so a regex engine matches it literally — with the exact rules of PCRE, JavaScript, Python, Go/RE2, .NET, Java, Ruby, or Rust. Runs in your browser; nothing is uploaded.

Try:
Escaped literal

About this tool

Regex Literal Escape turns arbitrary text into a regex-safe literal, so the pattern matches the text itself instead of treating punctuation as regex syntax. It is useful when you interpolate user input into a larger pattern, build search tools, generate deny-list rules, or need to paste a literal URL/path into a regex tester.

Different engines escape different character sets, so the tool includes nine flavors:

Use delimiter when your regex language also needs the pattern delimiter escaped, such as / in /.../. Turn on escape_whitespace for extended/free-spacing modes where a raw space can be ignored. Turn on string_literal when you want the escaped regex text double-escaped for a source-code string.

Worked example

Input:

a.b*c+(d)

With flavor=pcre, the output is:

a\.b\*c\+\(d\)

That pattern matches the literal characters a.b*c+(d), not "a, any character, b repeated, c, one or more...".

Limits and edge cases

FAQ

Why do different flavors produce different output?

Regex engines do not all treat punctuation the same way. For example, Go/RE2 leaves - and # alone, while PCRE and Rust escape them. Pick the flavor that matches the engine where you will run the pattern.

Should I enable string literal escaping?

Enable it only when you are pasting the result inside quoted source code, such as a JavaScript, C#, Java, or Go string. If you are pasting directly into a regex field or a raw string, leave it off so backslashes are not doubled.

What is the delimiter field for?

Some regex syntaxes wrap patterns in a delimiter, for example /literal/ in JavaScript or PHP. If your literal text can contain that delimiter, set delimiter=/ so the delimiter is escaped too.

Does this validate that my whole regex is correct?

No. This tool escapes literal text. It does not parse or validate a larger regex. Use the escaped output as one safe literal fragment inside your own pattern.

Developer & Automation Access

Run it from the terminal

Same engine as this page, headless — via the gizza CLI:

gizza tool regex-literal-escape "a.b*c+(d)"

New to the CLI? Get gizza →

Open it by URL

Pre-fill and auto-run this tool with query parameters — the names match the API/CLI:

https://gizza.ai/tools/regex-literal-escape/?text=a.b%2Ac%2B%28d%29&flavor=pcre&delimiter=%2F&escape_whitespace=true&string_literal=true

Machine-readable descriptor: tool.json — title + parameters JSON Schema for agents.