Python String Escape / Unescape
NOVOPython 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.
Funciona 100% no seu navegador — o que você insere nunca é enviado nem armazenado nos nossos servidores.
Esta ferramenta ainda não está totalmente traduzida, por isso parte do texto continua em inglês. A ferramenta funciona da mesma forma em todos os idiomas.
'It\'s a "quoted" path: C:\\temp\\new\nCafé ☕ costs 3 €'
Exemplos rápidos
Entradas típicas e os resultados que esta ferramenta gera.
Visão geral
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.
Por que usar esta ferramenta?
- 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
Recursos
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.
Como usar
Pick a direction
Text → Python literal to escape, Python literal → Text to decode.
Set the options
Choose quotes, non-ASCII handling and the raw string option.
Paste your input
The literal or decoded text updates as you type.
Copy the output
Copy it into your code, or reverse it to check the round trip.