HTML Entity Encoder and Decoder
Encode and decode HTML named, decimal and hexadecimal entities.
Escape plain text for use inside Python string literals, or decode supported Python-style escape sequences back into readable text. Convert quotes, backslashes, line breaks and Unicode escapes locally in your browser without executing Python code.
Input is treated as text content, not executable Python source.
The selected delimiter controls whether single quotes or double quotes are escaped.
When enabled, non-ASCII characters use Python-compatible \xNN, \uNNNN or \UNNNNNNNN escapes.
Optional normalization may change how some Unicode characters are represented.
This Python string escape tool prepares plain text for a Python string literal and decodes supported Python escape sequences back into readable text. It escapes quotes according to the selected quote style, escapes backslashes and common control characters, optionally converts non-ASCII characters, and runs locally in the browser. It does not add a variable assignment, parse complete Python source, call eval, import modules or evaluate expressions.
Plain-text input:
User "admin"
Path: C:\Tools\Unicode
Message: café
Escaped for a double-quoted Python string:
User \"admin\"\nPath: C:\\Tools\\Unicode\nMessage: café
The tool returns escaped string content only. Placed in Python source, that content can be used like this:
message = "User \"admin\"\nPath: C:\\Tools\\Unicode\nMessage: café"
Single-quoted example:
message = 'It\'s stored in C:\\Tools\\Unicode'
Python supports both single-quoted and double-quoted strings. The selected delimiter determines which quote character must be escaped, while backslashes and control characters still need consistent escaping. This converter does not unnecessarily escape the opposite quote character.
| Input character or sequence | Single-quoted mode | Double-quoted mode |
|---|---|---|
| Backslash | \\ | \\ |
| Single quote | \' | Preserved |
| Double quote | Preserved | \" |
| Newline | \n | \n |
| Tab | \t | \t |
| Non-ASCII character | Preserved by default, escaped when selected. | Preserved by default, escaped when selected. |
Unescape mode supports one layer of \\, \', \", \n, \r, \t, \b, \f, \v, \xNN, \uNNNN and \UNNNNNNNN. Malformed sequences such as \xG1, short Unicode escapes or out-of-range values are preserved and reported instead of being silently corrupted. The tool does not implement \N{name}, octal escapes, raw-string parsing or full Python source parsing.
Escape double quotes when the content will be placed inside a double-quoted Python string, and escape single quotes when it will be placed inside a single-quoted string. Backslashes are escaped as \\, so a Windows path such as C:\Tools\Unicode becomes C:\\Tools\\Unicode in a normal Python string literal.
Unicode characters are preserved by default. When “Escape non-ASCII characters” is enabled, this tool uses \xNN for U+0080 through U+00FF, \uNNNN through U+FFFF, and \UNNNNNNNN for supplementary-plane code points. Unescape mode validates code-point ranges and does not generate invalid surrogate output.
Python raw strings reduce the need to escape backslashes, which can make Windows paths and regular expressions easier to read. For example, r"C:\Tools\Unicode" preserves the backslashes. Raw strings still have syntax limitations and cannot end with an odd number of backslashes. A normal Python string path can be written as path = "C:\\Tools\\Unicode".
repr() returns a developer-oriented representation and usually includes surrounding quote characters. This page returns escaped string content by default, so you can paste the result between your chosen quote delimiters. Results may differ from Python’s version-specific repr() details because quote style and non-ASCII handling are explicit controls here.
This tool processes text with JavaScript directly in your browser. Your input is not submitted to UnicodeNow servers. Input is treated only as text, and the converter does not execute Python code, import modules or evaluate expressions.
Choose Escape, select the quote style, paste text content and process it. The output is escaped string content that can be placed between your chosen Python quote delimiters.
Use double-quoted mode to escape double quotes as \" or single-quoted mode to escape single quotes as \'. The opposite quote character is left alone unless another option requires escaping.
Choose Unescape and paste supported Python-style escape notation such as \n, \t, \xNN, \uNNNN or \UNNNNNNNN. The parser decodes one syntax layer without executing Python.
repr() returns a developer-oriented representation and usually includes quote characters. This tool returns escaped string content by default, with behavior controlled by the selected quote style and non-ASCII option.
\xNN represents a two-digit byte-sized value, \uNNNN represents a BMP code point and \UNNNNNNNN represents a supplementary code point. Invalid Unicode scalar values are preserved and reported.
Raw strings can make paths easier to read, such as r"C:\Tools\Unicode", but they still have syntax limits and cannot end with an odd number of backslashes.
No. Input is treated as text content only. The converter does not execute Python code, call eval, import modules or evaluate expressions.
No. This browser-local converter processes text with JavaScript and does not submit your input to UnicodeNow servers.
Working with another format? Use the JSON Escape and Unescape tool for JSON string content, the JavaScript Escape and Unescape tool for JavaScript literals, or the Unicode Escape Converter for sequences such as \u00E9.
Encode and decode HTML named, decimal and hexadecimal entities.
Escape and unescape JSON string content safely.
Escape JavaScript string literals and decode JS escape notation without eval.
Escape and unescape PHP-style single and double quoted strings.
Convert text to and from Unicode escape sequences and numeric entities.
Escape and decode XML entities and numeric character references.
Unicode defines characters and code points. UTF-8 encodes those code points as bytes for files, databases, web pages, APIs and network messages.
Learn what Unicode code points are, how U+ notation works, and how code points differ from glyphs, bytes, code units and visible characters.
Learn how Unicode escape syntax works across JavaScript, JSON, Python, PHP, Java, HTML, CSS and URLs.