Remove Backslash from Text
Strip backslash characters from any text. Useful for cleaning escaped JSON strings, regex patterns, Windows file paths, and LaTeX. Options for stripping single backslashes, collapsing double backslashes, and unescaping common sequences (\n, \t, \").
How to remove backslashes from text
1. Paste your text
Drop any text containing backslashes: escaped JSON, Windows file paths (C:\Users\...), regex patterns (\d{3}-\d{4}), LaTeX source, or programming strings with escape sequences. The cleaned version appears in the lower textarea on every keystroke.
2. Pick the right mode
Four modes handle different cases:
- Strip all backslashes removes every backslash regardless of context. Aggressive but useful when you know the backslashes are pure noise.
- Collapse double backslashes turns
\\into\. Useful for Windows paths that were stored in a JSON or programming string and got double-escaped. - Unescape sequences converts
\nto a real newline,\tto a tab,\"to a quote, etc. Useful when reading raw stringified data. - JSON unescape (full) performs a complete JSON-style unescape, including unicode escapes
\u00E9. Useful when copying a value out of a JSON file's escaped string field.
3. Preserve regex toggle
If your text is a regex pattern, you may want to keep \d, \w, \s, and \b (digit, word, whitespace, word-boundary metacharacters) intact while stripping other backslashes. Turn on "Preserve regex" when in Strip All mode to keep those four sequences.
4. Copy or download
Copy puts the cleaned output on the clipboard. Download .txt grabs a file. The Backslashes removed counter in the sidebar confirms how many backslashes were stripped, useful for sanity-checking.
When you need to remove backslashes
JSON value extraction
JSON strings escape internal quotes as \", newlines as \n, and backslashes themselves as \\. When copying a value out of a JSON file for use in plain text, the backslash escapes need to be removed or unescaped. Use JSON unescape mode for full handling.
Windows file path normalization
Windows uses backslash as the path separator: C:\Users\john\Documents\file.txt. When passing this path through systems that interpret backslash as an escape character (Python source, JSON, JavaScript strings, regex), the backslashes get doubled (C:\\Users\\john\\...) or fully escaped. Strip them with Strip All mode, or use the path with forward slashes (which Windows accepts) by replacing first.
Regex pattern simplification
Regex patterns often have lots of escape characters: \.\d{3}-\d{4}. When converting a regex to a plain-text template (sample inputs for documentation), strip the backslashes to get the human-readable pattern.
LaTeX cleanup
LaTeX commands start with backslash (\section{...}, \textbf{...}). To convert LaTeX source back to plain text, strip the backslashes (and then strip the braces with another tool). Useful when migrating from LaTeX to markdown or HTML.
Programming string literal cleanup
String literals in C, Java, Python, JavaScript all use backslash for escapes. When extracting a string value from source code for use in a document, strip the backslashes. Use Unescape mode if you want the actual newlines and tabs in the output.
SQL string escape removal
SQL escapes single quotes as \\' in some dialects (MySQL). Stripping these escapes gets the human-readable string. (For Postgres, single quotes are escaped by doubling, not backslash.)
Backslash escape sequences explained
| Sequence | Meaning | Context |
|---|---|---|
\n | Newline (line feed) | JSON, C, Java, Python, JS strings |
\r | Carriage return | Same as above; Windows files use \r\n for line endings |
\t | Tab | Same |
\" | Literal double quote | Inside double-quoted strings |
\' | Literal single quote | Inside single-quoted strings (Python, JS, SQL MySQL) |
\\ | Literal backslash | Universally |
\b | Backspace (or word boundary in regex) | Context-sensitive: control char in strings, anchor in regex |
\f | Form feed | Rare; some legacy formats |
\0 | Null character | C-family languages |
\uHHHH | Unicode code point (4 hex) | JSON, JS, Java, Python (with u prefix) |
\xHH | Byte (2 hex) | C-family, regex |
\d | Digit (regex metacharacter) | Regex only - equivalent to [0-9] |
\w | Word character (regex) | Regex only - [a-zA-Z0-9_] |
\s | Whitespace (regex) | Regex only - space, tab, newline, etc. |
Single vs double backslash: the doubling problem
A Windows path like C:\Users\file.txt contains 3 backslashes. When this path is stored in a JSON string, each backslash gets escaped as \\, so the JSON value reads "C:\\Users\\file.txt". When that JSON is then escaped again (for inclusion in another JSON), each \\ becomes \\\\ and the path looks like "C:\\\\Users\\\\file.txt".
Use the "Collapse double" mode to peel one layer of escaping off. Each pass reduces double backslashes to single. Run twice to peel two layers, three times to peel three. Each pass also removes any escape sequences (\n, \t) that may have been double-escaped, restoring them to the next-shallower form.
For one-shot full unescape regardless of depth, use JSON unescape mode which uses the browser's JSON.parse() to do a complete single-layer unescape with full Unicode handling.
Privacy and processing
All conversion runs in your browser. JSON values, file paths, regex patterns, programming strings, and any confidential text stay local. The tool does not log keystrokes, does not transmit the input, and does not store the source. Safe for any text that contains internal IDs, secrets, or private data.
Related tools
Frequently asked questions
How do I remove all backslashes from text?
Paste the text into the textarea and the default 'Strip all backslashes' mode removes every backslash regardless of context. Output appears in the lower textarea automatically. Click Copy to put it on your clipboard.
How do I convert double backslashes to single?
Pick 'Collapse double' from the Mode dropdown. Each pair of consecutive backslashes (\\) becomes a single backslash. Useful for Windows paths stored in escaped JSON or string literals.
How do I unescape \n and \t into real newlines and tabs?
Pick 'Unescape sequences'. The tool converts \n to a real newline character, \t to a tab, \r to a carriage return, \" to a real double quote, \' to a single quote, and \\ to a literal backslash. Useful when reading stringified data.
What does JSON unescape mode do?
Performs a complete JSON-style unescape using the browser's JSON.parse(). Handles all standard escape sequences (\n, \t, \", \\) plus unicode escapes (\u00E9 becomes é). Use when copying a value out of a JSON file's escaped string field.
How do I preserve regex metacharacters like \d and \w?
Turn on 'Preserve regex \d \w \s' in the sidebar. With Strip All mode, the four regex shorthands (\d, \w, \s, \b) are preserved while all other backslashes are stripped. Useful when cleaning a regex pattern without breaking its functionality.
Will it handle Windows file paths?
Yes. A Windows path 'C:\Users\file.txt' with single backslashes can be stripped (Strip All) to get 'C:Usersfile.txt' or you can replace backslashes with forward slashes after stripping. If the path is double-escaped (from JSON), use Collapse Double first.
What about LaTeX source code?
Strip All mode removes the backslashes that start LaTeX commands (\section, \textbf), leaving the bare command name in the text. To fully convert LaTeX to plain text, combine with the brace-removal step (use word-replacer to strip { and }).
Is the text sent to a server?
No. All conversion runs in your browser. JSON values, file paths, regex patterns, and any confidential text stay on your device. The tool makes no network call when you paste or copy.
More wordcounter.ai tools
Other tools you might find useful.