Online Java String Escape Tool - Escape Text for Java String Literals

Online Java String Escape Tool

This tool escapes special characters in text so it can be safely used in Java string literals. It converts characters like quotes, backslashes, newlines, tabs, and other control characters into their escaped representations (e.g., \" \\ \n \t).


Online Java String Escape
 

The text which will be escaped for use in Java string literals


                        

What is Java String Escaping?

Java string escaping is the process of converting special characters into escape sequences that can be safely included in Java string literals. When you include a string in Java code, certain characters have special meaning and must be escaped with a backslash (\).

Common Java Escape Sequences

Character Escape Sequence Description
" \" Double quote
' \' Single quote
\ \\ Backslash
Newline \n Line feed (LF)
Carriage Return \r Carriage return (CR)
Tab \t Horizontal tab
Backspace \b Backspace
Form Feed \f Form feed

How to use this tool?

  1. Enter or paste your text in the input area above.
  2. Click the "Escape for Java" button.
  3. The escaped output will be displayed, ready to copy into your Java code.
  4. Use the Java Unescape tool to convert escaped text back.

Example

Input: Hello "World"
How are you?

Output: Hello \"World\"\nHow are you?

Search Tutorials