⚡
usefultools.dev
r""

Python String Escape / Unescape

NOUVEAU

Python string escape tool: turn text into a valid Python string literal with the quotes you choose, or decode a literal with \n, \x, \u and \N{…} escapes. Free.

Fonctionne à 100 % dans votre navigateur — vos données ne sont jamais envoyées ni stockées sur nos serveurs.

Cet outil n'est pas encore entièrement traduit : une partie du texte est encore en anglais. L'outil lui-même fonctionne de la même façon dans toutes les langues.

Python literal
'It\'s a "quoted" path: C:\\temp\\new\nCafé ☕ costs 3 €'
⚡

Exemples rapides

Des entrées typiques et les résultats produits par cet outil.

Escape
It's
'It\'s'
Raw
C:\temp
r'C:\temp'
Non-ASCII
café
'caf\xe9'
\U
😀
"\U0001f600"
Unescape
'\N{EURO SIGN}5'
€5
📖

Présentation

Pasting text into Python source code breaks as soon as it contains a quote, a backslash or a line break. This Python string escape tool turns any text into a valid string literal: pick single, double or triple quotes, ask for a raw string when the text allows one, and choose whether accents and emoji stay as they are or become \x, \u and \U escapes.

The reverse direction reads Python literals the way the interpreter does: \n, \t, octal, \xhh, \uXXXX, \UXXXXXXXX and a common set of \N{NAME} escapes, r, b, u and f prefixes, triple quotes and adjacent literals that Python joins together. Invalid escapes such as "\d" are kept and flagged, just like Python's SyntaxWarning, and real errors show their line and column.

The tool never runs Python or evaluates your input; it parses the text in your browser and uploads nothing.

Pourquoi utiliser cet outil ?

  • Paste any text safely into Python code
  • Raw strings for Windows paths and regex
  • Read escaped strings from logs and repr() output
  • Flags invalid escapes before Python does
  • No code execution, runs in your browser
⭐

Fonctionnalités

❝

Four quote styles

Single, double, triple-single or triple-double quotes; only the quotes that need it are escaped.

🅡

Raw string option

Produces r'…' when possible and explains why when it is not, for example a trailing backslash.

🌐

Non-ASCII control

Keep accents and emoji or write them as \xe9, \u20ac or \U0001f600.

🔓

Full unescaping

Handles \n \t \\, octal, \x, \u, \U and common \N{NAME} escapes, plus b'…' bytes literals.

⚠️

Error positions

Unterminated strings, truncated \x escapes and unknown names are reported with line and column.

🛠️

Mode d'emploi

1

Pick a direction

Text → Python literal to escape, Python literal → Text to decode.

2

Set the options

Choose quotes, non-ASCII handling and the raw string option.

3

Paste your input

The literal or decoded text updates as you type.

4

Copy the output

Copy it into your code, or reverse it to check the round trip.

🤔

Questions fréquentes