Java String Escape & Unescape
Convert ordinary text to a Java-compatible quoted string literal, or decode supported Java escape sequences back into text.
Java String Escape & Unescape workspace
Java String Escape & Unescape example
Escape mode with quoted output enabled and non-ASCII escaping disabled.
Example input
Hello, "SiteSCS"!
Path: C:\toolsExpected output
"Hello, \"SiteSCS\"!\nPath: C:\\tools"How to use Java String Escape & Unescape
- 1
Choose Escape or Unescape.
- 2
Paste text or use the tested sample.
- 3
Choose whether to wrap the result in quotes or escape non-ASCII UTF-16 code units.
- 4
Run the conversion, then copy or download the result.
What this tool does
Escape mode protects backslashes, double quotes, control characters, tabs, and line endings so text can be pasted into a Java string literal.
Unescape mode accepts either a quoted literal or raw escaped content and decodes Java's standard single-character, Unicode, and octal escapes.
Features and options
- Quoted or unquoted output
- Optional non-ASCII Unicode escaping
- Standard Java escapes including \n, \t, \r, quotes, and backslashes
- Unicode \uXXXX and Java octal decoding
- UTF-16-safe browser processing
Technical information
The escaper iterates over JavaScript UTF-16 code units. Supplementary Unicode characters are therefore represented by a surrogate pair when non-ASCII escaping is enabled, matching Java's UTF-16 source model.
The decoder rejects trailing backslashes, unmatched outer quotes, malformed Unicode sequences, and unsupported escape markers instead of silently changing them.
Common use cases
- Embedding text in Java source
- Preparing test fixtures and log messages
- Inspecting escaped API or configuration values
- Decoding Java literals during debugging
Limitations
- This is a string-literal converter, not a Java compiler.
- It does not parse text blocks, concatenated expressions, variables, or source-code comments.
- Unicode escapes are decoded as a convenience even though the Java compiler processes them before ordinary literal escapes.
Related tools
References & Sources
Defines Java escape sequences for character literals, string literals, and text blocks.
Verified 2026-08-13 ↗docs.oracle.com · Official DocumentationJava SE 21 String APIDocuments Java strings and the platform's escape-translation behavior.
Verified 2026-08-13 ↗Java String Escape & Unescape FAQ
Does this support Unicode?
Yes. Unicode text is preserved by default. The optional Unicode mode emits non-ASCII UTF-16 code units as \uXXXX sequences.
Can it validate a complete Java expression?
No. It converts the contents of a single string literal and does not compile or evaluate Java source.