Java / .NET String Escape
Escape text into a Java or C# (.NET) string-literal-safe form — quotes, backslashes, control characters and optional \uXXXX for non-ASCII — or unescape \n, \t, octal, \xH, \uXXXX and \UXXXXXXXX sequences back into plain text.
Input
Output
More ways to use this tool
REST API
curl -X POST https://api.iotools.cloud/v1/tool/java-dotnet-string-escape \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"inputText": "He said \"Hi\"\n\tC:\\Users",
"language": "java",
"mode": "escape",
"escapeNonAscii": "false"
}'Swap in your own key from your account. The tool's fields are the body — no wrapper.
Ask an AI agent
Use the IOTools `java-dotnet-string-escape` tool (Java / .NET String Escape) on this input:
YOUR_INPUT_HEREPaste this at any agent connected to the IOTools MCP server, then add your input.
Embed widget
<iframe
src="https://iotools.cloud/embed/java-dotnet-string-escape/"
width="100%" height="520" frameborder="0" scrolling="no" loading="lazy"
title="Java / .NET String Escape — iotools.cloud"
sandbox="allow-scripts allow-forms allow-same-origin allow-downloads allow-popups allow-popups-to-escape-sandbox"
allow="clipboard-write"
style="width:100%;border:1px solid #e5e7eb;border-radius:12px;overflow:hidden"></iframe>
<script src="https://iotools.cloud/embed.js" async></script>Drop this into your own page — free, no key required, just a link back.
| Cost per API/MCP call | From 5 credits |
|---|---|
| Need more credits? | View pricing |
Also available with
Guides
The Java / .NET String Escape tool converts text to and from the form it takes inside a Java or C# string literal. Paste raw text to get a version that is safe between quotes in your source code, or paste an escaped literal to get the original characters back. Everything runs in your browser.
What it does
Escape backslash-escapes the characters that would break a string literal:
- Backslash, double quote and single quote become
\\,\"and\' - Newline, carriage return, tab, backspace and form feed become
\n,\r,\t,\band\f - In C# mode the bell, vertical tab and null character become
\a,\vand\0 - Other control characters become
\uXXXXin C#, and 3-digit octal such as\001in Java
Java translates \uXXXX escapes before it tokenizes the source, so a control character written as \u000a would actually break the literal. That is why Java mode uses octal for control characters.
Tick Escape non-ASCII to turn every character above ~ into \uXXXX. Emoji become surrogate pairs (two escapes), which both languages accept.
Unescape reverses it. Java mode understands \b \t \n \f \r \s, quotes, backslash, octal \0–\377 and \uXXXX (including the \uuuu0041 form). C# mode understands \a \b \f \n \r \t \v \0, quotes, backslash, \xH to \xHHHH, \uXXXX and \UXXXXXXXX.
How to use it
- Paste your text.
- Pick Java or C# / .NET, then Escape or Unescape.
- Copy or download the result.
Does it add surrounding quotes?
No. The output is the string contents only, so you can paste it into any literal.
What happens with an unknown escape?
The backslash is dropped and the character kept (\q becomes q). Malformed numeric escapes degrade the same way instead of raising an error.
Does it handle C# verbatim strings?
No — it targets regular (non-@) literals. Verbatim strings only double their quotes.
Related tools: JavaScript Escape / Unescape, JSON Escape / Unescape.