Java Escape/Unescape

Form of Java Escaping/Unescaping

Enter java code here to escape/unescape:


Move to «Paste Code» for Save it

About online Java escape/unescape

About Java escape/unescape

Escapes or unescapes a Java string removing traces of offending characters that could prevent compiling.

The Java Escape / Java Unescape tool was created to help with escape special unicode characters into a quoted string literal value for Java source code and also unescape it.

What characters are replaced?

The following characters are reserved in Java and must be properly escaped to be used in strings:

  • Backspace is replaced with \b
  • Newline is replaced with \n
  • Tab is replaced with \t
  • Carriage return is replaced with \r
  • Form feed is replaced with \f
  • Single quote is replaced with \'
  • Double quote is replaced with \"
  • Backslash is replaced with \\

How it Works?

Just paste your Java code to the textarea above and click to the button "Escape" or "Unescape" and you will get your escaped/unescaped data.

Example of Java Escaping

Java code, before:
import java.io.*;
class MyFirstProgram {
	/** Print a hello message */
	public static void main(String[] args) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System. in ));
		String name = "Instructor";
		System.out.print("Give your name: ");
		try {
			name = in .readLine();
		} catch (Exception e) {
			System.out.println("Caught an exception!");
		}
		System.out.println("Hello " + name + "!");
	}
}
After:
import java.io.*;\r\nclass MyFirstProgram {\r\n\t/** Print a hello message */\r\n\tpublic static void main(String[] args) {\r\n\t\tBufferedReader in = new BufferedReader(new InputStreamReader(System. in ));\r\n\t\tString name = \"Instructor\";\r\n\t\tSystem.out.print(\"Give your name: \");\r\n\t\ttry {\r\n\t\t\tname = in .readLine();\r\n\t\t} catch (Exception e) {\r\n\t\t\tSystem.out.println(\"Caught an exception!\");\r\n\t\t}\r\n\t\tSystem.out.println(\"Hello \" + name + \"!\");\r\n\t}\r\n}
After the conversion, you can apply the Java code to your project or use it for some other purpose.