DEVELOPER TOOL

Python String Escape / Unescape

Convert text to a Python string literal (or back), in any quote style.

About this tool

Turn plain text into a properly escaped Python string literal — pick single, double, triple-quoted, raw, or f-string style — or go the other way, parsing a Python string literal (with its quotes and escapes) back into plain text.

Frequently asked questions

What does the "raw" style do?
Raw strings (r"...") treat backslashes as literal characters instead of escape sequences — useful for regex patterns and Windows file paths. Note that a raw string still can't end in an odd number of backslashes; this tool falls back to normal escaping if your text would make that invalid.
What does the f-string option actually do?
It wraps your escaped text in f"..." quotes and doubles any literal curly braces ({{{) so they're treated as literal text rather than an interpolation placeholder — it doesn't evaluate or insert any variables.
Does "Python literal → Text" handle every valid Python string?
It covers the common cases: all quote styles, standard backslash escapes, \xNN and \uNNNN escapes, and string-type prefixes (r, b, f, u). Exotic cases like \N{...} named Unicode escapes aren't supported.