What this tool does
It escapes text for a Java String literal, with one behaviour that sets it apart from the JavaScript and C# escapers: everything above ~ (U+007E) is written as \uXXXX.
- backslashes are doubled;
"is escaped — and'is not, because Java has no single-quoted string;- newline, carriage return, tab, backspace and form feed get
\n,\r,\t,\b,\f; - control characters and every non-ASCII character become
\uXXXX, with characters outside the Basic Multilingual Plane written as a surrogate pair.
When you need it
Pasting text into a .java file whose encoding you do not control, and above all into a .properties file — those are specified as ISO-8859-1, and \uXXXX is the only portable way to carry an accent or a kanji through one.
What it does not do
The ASCII-only output is verbose by design. If you are targeting a modern UTF-8 source file and want a literal a human can still read, the JavaScript escaper leaves non-ASCII characters intact and produces the same result for everything else that matters here.
Private by design
Everything runs locally in your browser with JavaScript. Your data is never uploaded, which makes the tool safe for sensitive content, and it keeps working offline.