Skip to content
Jellykit

Python String Escape

Escape text for a Python string literal (quotes, backslashes, newlines, \x and \u codes) or decode escape sequences back to text. Free online Python escaper.

Runs in your browser. Nothing is uploaded.

About Python String Escape

Python Escape converts any text into the body of a Python string literal for the quote style you pick, escaping backslashes, that quote and control characters. The ASCII option writes other characters as \xNN, \uNNNN or \UNNNNNNNN, just like Python's repr().

Unescape decodes those sequences back into text, which is handy for reading byte strings and escaped values printed by Python.

How to use Python String Escape

  1. Type or paste your text into the input box. Press Sample to see an example.
  2. Adjust the options. The result updates as you type.
  3. Copy the result, or press Use as input to chain another transformation.

Frequently asked questions

What about raw strings?

Raw strings (r"...") don't process escapes, but they can't end with an odd number of backslashes. Escaping is the safer general choice.

Is this the same as repr()?

Very close. repr() picks the quote style automatically, while here you choose it.

Is Python String Escape free and private?

Yes. Python String Escape is completely free with no sign-up. Everything runs in your browser, so whatever you type or paste never leaves your device.

See all developer tools →