About the Backslash Tool
A backslash is the escape character in many programming languages and file formats. Putting one before a quote tells the program that the quote is part of the text, not the end of it. This tool adds backslashes before single quotes, double quotes and backslashes, the way PHP's addslashes function does, and it also removes them again, like stripslashes. Choose the direction, paste your text and see the result with a count of backslashes before and after. A null character is written as backslash zero. Everything happens in your browser and the text is not uploaded.
Updated October 2026
How to use the Backslash Tool
- 1Paste your text into the left box.
- 2Choose Add backslashes or Remove backslashes.
- 3Read the result on the right.
- 4Check the note with the number of backslashes before and after.
- 5Copy the result or download it as a text file.
What escaping is for
Programs read quotes as the edges of a piece of text. If the text contains a quote, the program would think the text had ended. A backslash in front of the quote says: treat the next character as plain text. Without escaping, a name like O'Brien can break a database query or a script.
Adding backslashes is the quick way to make a snippet safe to paste inside a string. It is not a replacement for proper escaping or parameterised queries in real software.
Removing backslashes
Text copied from logs, exports and old databases often has extra backslashes before every quote. Removing them gives you the text as it was meant to look. If you remove too many, or the text had real backslashes you wanted to keep, paste the original again and try adding instead.
The note under the result counts backslashes before and after, so you can see how many were added or removed.
- Quotes escaped twice
- Paths copied from code
- Text exported from old systems
Good habits
Do a quick check with a short sample before using the output in code. Remember that different languages have different escape rules: this tool follows the simple PHP-style rule. For regular expressions, URLs, HTML and JSON, use the tool made for that format.
Examples that show the difference
The text 5 o'clock, "sharp" gains three backslashes when added: one before the apostrophe and one before each double quote. The folder name C:\Users\Ann gains a backslash before each of its two existing backslashes. Removing them from the escaped version returns the first form exactly, so the process can be reversed. When you work with JSON text, the Text Formatter tidies the rest, and the Find and Replace Text tool fixes the odd stray character.
Features
- Adds backslashes before quotes and backslashes
- Removes backslashes with one click
- Same behaviour as PHP addslashes and stripslashes
- Counts backslashes before and after
- Copy or download
- Private: nothing is uploaded
Frequently asked questions
What does adding backslashes do?
It puts a backslash before every single quote, double quote and backslash, so that the text can sit inside a quoted string in code without ending it early. The text It's "fine" becomes It\'s \"fine\".
What does removing backslashes do?
Each backslash is dropped and the character after it is kept. A double backslash becomes a single one, and backslash zero becomes a null character. Text without backslashes is left as it was.
Is this the same as PHP addslashes?
It follows the same rule: it escapes single quotes, double quotes, backslashes and the null character. It is handy for checking what the PHP function would return without running any code.
Is this the same as JSON escaping?
Not exactly. JSON strings also escape line breaks and tabs and do not escape single quotes. For JSON, use the JSON Escape Tool on this site.
Why do Windows paths have so many backslashes?
A path like C:\temp\file.txt has backslashes as folder separators. In code, each backslash must itself be escaped, so it is written with two. Adding slashes to the path shows you that doubled form.
Is my text uploaded?
No. The change is done in your browser, and nothing is sent to a server.