PHP Escape and Unescape Tool for PHP String Literals
This PHP string escape and unescape tool converts pasted PHP text using the quoting rules you select. Single-quoted mode escapes only backslashes and apostrophes. Double-quoted mode escapes control characters and PHP special characters, and represents non-ASCII characters as \u{…} or legacy \xHH. When unescaping, it applies the rules for the selected mode.
PHP Escape and Unescape is a browser-based PHP string escape and unescape tool for preparing string content and reading escaped text. Paste or drop PHP input, choose whether to escape or unescape it, and select the quoting mode that matches your string. The output follows the rules for that mode rather than applying one set of escapes to every PHP string.
In single-quoted mode, the tool escapes only the backslash and apostrophe. In double-quoted mode, it handles \n, \r, \t, \v, \e, \f, \\, \$, and \", and represents non-ASCII characters as \u{…} or legacy \xHH. Unescaping uses the rules for the selected mode, so matching the mode to the input is important.
PHP single-quoted and double-quoted strings interpret escape sequences differently. This means that text escaped for one quoting style may not be suitable for the other. The tool helps you prepare string content according to the target style or reverse the supported escapes when you need to inspect the underlying characters.
The conversion runs entirely in your browser. Your input is processed on your own device and is not uploaded, stored, or sent anywhere; once the page has loaded, the tool works offline without a server connection. The tool is free to use.
This tool can help PHP developers, DevOps engineers, and anyone who needs to prepare or inspect PHP string content. It is useful when editing source code, handling nested strings, or checking what escaped text represents, without manually applying each supported escape rule.
Step 1: Paste or drop your PHP text into the tool. Add the string content you want to escape or unescape.
Step 2: Choose whether to escape or unescape the input. Escaping adds the relevant PHP escape sequences; unescaping turns matching sequences back into characters.
Step 3: Select the single-quoted or double-quoted mode. Each mode follows different PHP string rules, so use the one that matches your target string.
Step 4: Review the result and copy it. Double-quoted mode also represents non-ASCII characters as \u{…} or legacy \xHH.
Use case: Embed a PHP string inside another PHP string without breaking its quoting. Choose the matching quote mode so the tool applies the corresponding escape rules.
Use case: Make a densely escaped PHP string easier to read. Unescape it using the same mode that was used to escape it.
Use case: Prepare a string literal for pasting into PHP source code. Escaping backslashes and other relevant characters helps keep the intended text intact.
Use case: Inspect the characters represented by PHP escape sequences. Unescaping shows the resulting text instead of the escape notation.
Use case: Work with text that contains line breaks, tabs, or other characters supported by double-quoted mode. The tool applies the listed PHP escape sequences.
Use case: Handle non-ASCII text in a PHP string. Double-quoted mode represents these characters as \u{…} or legacy \xHH.