How to use Java Escape
- Paste or type the text you want to escape.
- Adjust the options if you need to.
- Copy the escaped result.
About Java Escape
In Java every double quote and backslash inside a string literal needs a backslash in front of it, and a line break has to be written as \n. Pasting a JSON payload, a SQL statement or a regular expression into a test class means doing that for every quote and backslash by hand, and regular expressions double the backslashes again.
The tool produces exactly the escapes the Java language specification defines, so the output can be placed between double quotes in your source. If you are on Java 15 or later you can also use text blocks, which need far less escaping.
What gets escaped
Backslash becomes \\, a double quote becomes \", newline \n, carriage return \r, tab \t, backspace \b, form feed \f. Other control characters turn into \uXXXX.