Java Escape Text Online Tool
Overview
Converts text containing special characters in Java to escape sequences. Java allows string literals to convert certain characters into escape sequences with characters used for structuring the code being mandatory to convert. This tool will convert plain text into escaped text for use in Java string literals.
How to Use
1. Enter your text into the input box.
2. Press the "Escape" button and the text will be converted into Java escaped text in the output box.
3. Pressing the "Unescape" button will unescape the text in the output box back to the input box.
Options
Escape non-required characters: Check to escapes the special characters that are not required to be escaped in Java. In Java the required mandatory characters are the backslash character (\), newlines, and the quotes surrounding the String. The non-required characters are backspace (\b), tab (\t), and form feed (\f).
Quotes: Specifies the quotes surrounding the string literal. The quotes the mandatory required characters to be escaped. When the same type of quotes appear in the string literal, they are required to be escaped.
Escape non-ASCII: Controls whether non-ASCII characters will be escaped into Java Unicode escape format.
About Java escape sequences
Java uses escape sequences to encode special characters in String literals. Some of these characters are used to define the structure of Java code so they cannot be used directly in String literals because they would be interpreted as structural marks. Other characters are formatting characters that might look strangely when directly included as String literals.
Escape Sequence | Description |
---|---|
\t |
Insert a tab in the text at this point. |
\b |
Insert a backspace in the text at this point. |
\n |
Insert a newline in the text at this point. |
\r |
Insert a carriage return in the text at this point. |
\f |
Insert a form feed in the text at this point. |
\' |
Insert a single quote character in the text at this point. |
\" |
Insert a double quote character in the text at this point. |
\\ |
Insert a backslash character in the text at this point. |
Java also allows has escape sequences for Unicode characters. The escape sequence is "\u" followed by the four hex digit UTF-16 code for the character. Unicode escape characters are useful if the text encoding only allows for ASCII encoding and Unicode characters are needed in the String literal.
Escape Sequence | Result |
---|---|
\u00c0 |
À |
\u4e2d |
中 |
\ud83d\udea6 |
🚦 |