Java Escape Unescape

Turn plain text into valid Java string literal content and back. Fix quotes, backslashes, and control characters so you can paste safely into source code or config.

0 chars in0 sequences out

Java escape sequences

CharEscapeUnicodeDescription
"\"\u0022Double quote
'\'\u0027Single quote
\\\\u005CBackslash
newline\n\u000ALine feed
tab\t\u0009Horizontal tab
carriage return\r\u000DCarriage return
backspace\b\u0008Backspace
form feed\f\u000CForm feed

When Java string escaping matters

Java string escaping adds backslashes before special characters in string literals so the compiler reads them correctly. Without it, a single quote or backslash in your text can break the literal or change the meaning of the next character.

Use escaping when you need to embed quotes, backslashes, newlines, or tabs inside a Java string, when building file paths or regex patterns in code, or when generating Java source. Use unescaping to turn stored or logged escape sequences back into readable text.

  • Prevents compilation errors when the string contains quote characters.
  • Lets you include newlines, tabs, and other control characters in literals.
  • Required for Windows paths and regex patterns that use backslashes.
  • Supports Unicode via \uXXXX sequences.

Java Escape Unescape FAQ

Common questions about escaping and unescaping Java strings.

What is the order of escaping in Java strings?

Escape backslashes first, then quotes and control characters. Our tool applies that order so you do not double-escape backslashes.

Does this tool handle Unicode \u escapes?

Yes. Unescape converts \uXXXX to the corresponding character. Escape does not convert characters to \u by default; it only escapes the standard set (quotes, backslash, n, t, r, b, f).

When should I use escape vs unescape?

Use Escape when you have plain text (e.g. from a form or file) that you want to paste into a Java string literal. Use Unescape when you have a string that already contains escape sequences and you want to see the real characters.

Is the conversion done in the browser?

Yes. Input and output are processed in your browser. Nothing is sent to a server, so your data stays private.