Java Unescape

Decode a Java literal back to the characters it actually represents.

Escaped text
Plain text
Runs locally in your browser

About the Java Unescape

Log lines, properties files and exception messages copied out of a Java project are often still in literal form. Paste one here and every escape is resolved: the six short forms, the doubled backslash, both quote characters, \s from the text-block syntax added in Java 15, octal escapes from \0 to \377, and Unicode escapes.

The Unicode handling covers a detail most converters miss. Java allows any number of u characters after the backslash, so \uu0041 and \uuuu0041 both mean the letter A. That rule exists so an already-escaped file can be escaped again without ambiguity, and it is decoded correctly here. Octal escapes are validated too: anything above \377 is out of range and reported rather than silently truncated.

Because Java has a fixed escape list, an unknown sequence is treated as an error rather than quietly dropping the backslash. That catches strings that were really written for another language, for instance a \x41 copied from C# or JavaScript. When that happens, run the text through C# Unescape or JavaScript Unescape instead. To go the other way, Java Escape rebuilds the literal.

How to use

  1. Paste the Java literal or the escaped fragment.
  2. Read the decoded text and copy it.
  3. If an error names an invalid escape, check which language the string really came from.

Common questions

Why does \uu0041 work?
The Java specification allows a run of u characters in a Unicode escape, so multiple us are legal and all decode to the same character.
Are octal escapes supported?
Yes, from \0 through \377. A value above that range is rejected because Java itself will not compile it.
What does \s decode to?
A single space. It was added for text blocks so trailing spaces survive the compiler stripping them.
Why do I get an error on \x41?
Java has no hexadecimal escape. That form belongs to C, C# or JavaScript, so the input was probably written for one of those languages.