100% local — your data never leaves your browser

Java Escape — Safe in an ASCII-Only Source

Escape text for a Java string literal. Every non-ASCII character becomes \uXXXX, so the result survives an ASCII-only source or a .properties file.

Instant Private Zero cookies

Text input

Java Escaped output

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.

Frequently asked questions

Why are my accented characters turned into \uXXXX?
That is the point of this escaper. Java source and .properties files are historically read as ISO-8859-1 or ASCII, so é is written \u00e9 to survive regardless of the file encoding. The Java compiler decodes it back before parsing.
What happens to emoji?
They become a surrogate pair — 😀 is written \ud83d\ude00. That is exactly how the character is stored in a Java String, which holds UTF-16 code units.
Are single quotes escaped?
No. Java has no single-quoted strings: ' delimits a char literal, never a String, so it needs no escaping inside one. Only the double quote is escaped.

Related converters