HTML Entity Encoder and Decoder
Encode and decode HTML named, decimal and hexadecimal entities.
Escape plain text for use inside PHP single-quoted or double-quoted string literals, or decode supported PHP-style escape sequences back into readable text. Quotes, backslashes, line breaks and control characters are processed locally in your browser.
Escape raw text for a PHP string literal or decode supported PHP-style escape sequences.
PHP single-quoted and double-quoted strings interpret backslash sequences differently.
Unicode normalization is optional and may change how some characters are represented.
This PHP string escape tool converts plain text into escaped content suitable for PHP string literals, or decodes supported PHP-style escape sequences back to readable text. It handles quotes, backslashes, common control characters and dollar signs in double-quoted strings. The converter treats input as text and never executes PHP code, evaluates variables or runs expressions.
Plain-text input:
User "admin"
Path: C:\Tools\Unicode
Price: $10
Escaped for a PHP double-quoted string:
User \"admin\"\nPath: C:\\Tools\\Unicode\nPrice: \$10
PHP code example:
$message = "User \"admin\"\nPath: C:\\Tools\\Unicode\nPrice: \$10";
Single-quoted PHP example:
$message = 'It\'s stored in C:\\Tools\\Unicode';
PHP interprets escape sequences differently depending on the delimiter. Double-quoted strings interpret common escape sequences and variable interpolation, so literal dollar signs should be escaped when the content must remain text. Single-quoted strings are simpler: only backslash and single quote need special treatment.
| Sequence | Single-quoted string | Double-quoted string |
|---|---|---|
\\ | Decoded as one backslash. | Decoded as one backslash. |
\' | Decoded as a single quote. | Preserved as a backslash plus quote by this tool unless single-quoted mode is selected. |
\" | Preserved literally. | Decoded as a double quote. |
\n | Preserved as backslash plus n. | Decoded as a line feed. |
\t | Preserved as backslash plus t. | Decoded as a tab. |
\$ | Preserved as backslash plus dollar sign. | Decoded as a literal dollar sign. |
Escape double quotes inside double-quoted PHP strings, single quotes inside single-quoted PHP strings, and backslashes where a literal backslash must survive the PHP parser. In double-quoted strings, escape dollar signs when user-provided text such as $10 must not be interpreted as variable interpolation.
Double-quoted mode supports \\, \", \$, \n, \r, \t, \v, \e, \f and generated \xHH escapes for other C0 controls. Single-quoted mode supports \\ and \'. Unsupported backslash sequences are preserved instead of executed or guessed.
addslashes() adds backslashes before selected characters, but it is not a complete serializer and it is not a substitute for SQL parameterization, HTML escaping, JSON encoding or context-aware output encoding. This page is for PHP string literal content, not database or browser security boundaries.
This tool processes text with JavaScript directly in your browser. Your input is not submitted to the server. The converter treats input as text only and does not execute PHP code, evaluate variables or run expressions.
Choose the PHP string type, paste raw text, then run Escape. The tool returns escaped string content for that delimiter style.
Escape double quotes as \" inside double-quoted strings and single quotes as \' inside single-quoted strings.
Choose Unescape and the matching string type. Supported PHP-style escape sequences are decoded back into text without executing PHP.
Yes. PHP single-quoted strings only interpret \\ and \' specially, while double-quoted strings also interpret escapes such as \n, \t and \$.
addslashes() adds backslashes before selected characters, but it is not a universal serializer and does not replace SQL parameters, HTML escaping or JSON encoding.
No. Input is treated as text only. The tool does not evaluate variables, run expressions or execute PHP code.
No. This browser-local tool does not submit, store or log your input on 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.
Convert Python string escapes without executing Python code.
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 how Unicode escape syntax works across JavaScript, JSON, Python, PHP, Java, HTML, CSS and URLs.
Compare literal Unicode characters, named HTML entities, numeric character references, code points and UTF-8 bytes.