Escape / Unescape
Java Escape / Unescape
Java-ready string literals from any text — full \uXXXX Unicode escaping for clean, ASCII-safe source files.
In short
Escape and unescape Java string literals online: quotes, backslashes, control characters, and \uXXXX Unicode escapes for non-ASCII text. Free, private.
By NaveenKumar T · Updated
- Escape & unescape in one tool
- Handles every special character
- Instant as you switch modes
Runs entirely in your browser — nothing you paste or open here is uploaded, logged, or stored.How we handle data →
Example
Java Escape: input and output
A message from a .properties file with umlauts, CJK text and an emoji, converted to an ASCII-only literal.
Willkommen, "Jürgen"! Größe: 5 × 3 m²
Tokyo → 東京 🗼 (tab-separated)Willkommen, \"J\u00fcrgen\"! Gr\u00f6\u00dfe: 5 \u00d7 3 m\u00b2\nTokyo \u2192 \u6771\u4eac \ud83d\uddfc\t(tab-separated)Every non-ASCII character became a \u escape — the tower emoji needed two, \ud83d\uddfc — while the newline was written as \n and the tab as \t rather than as \u000a and \u0009.
Learn more
Java escaping rules
Java string escaping covers the C-style basics — \" \\ \n \r \t \b \f — and, conventionally, \uXXXX Unicode escapes for everything beyond printable ASCII. This tool applies that convention: accented characters, symbols, and emoji become \u sequences (surrogate pairs for code points above U+FFFF), producing literals that survive any source-file encoding, build system, or code review tool.
Unescape mode reverses all of it, including \u pairs back to their characters — useful for reading .properties files and stack traces where the tooling escaped everything non-ASCII into unreadable soup.
Java escape sequences
JLS §3.10.6 defines exactly eight backslash escape sequences for character and string literals; everything else non-ASCII goes through the separate \uXXXX Unicode-escape mechanism (JLS §3.3), which this tool also applies on Escape.
| Escape | Character | Unicode code point |
|---|---|---|
| \b | Backspace | U+0008 |
| \t | Horizontal tab | U+0009 |
| \n | Line feed | U+000A |
| \f | Form feed | U+000C |
| \r | Carriage return | U+000D |
| \" | Double quote | U+0022 |
| \' | Single quote | U+0027 |
| \\ | Backslash | U+005C |
Help
Frequently asked questions
Everything you need to know about the Java Escape.
01How do I escape or unescape Java here?
Paste your text, pick Escape or Unescape in the Mode select, and press Convert. Escape produces an ASCII-only Java string literal — non-ASCII characters become \uXXXX escapes, with surrogate pairs above U+FFFF; Unescape reverses all of it, surrogate pairs included.
02Why escape non-ASCII characters as \uXXXX when Java supports UTF-8 sources?
Because the toolchain between you and production might not: build servers with mis-set encodings, diff tools, older editors. \u escapes make the string's bytes irrelevant — the literal is pure ASCII and means the same thing everywhere. It's the convention .properties files enforce for exactly that reason.
03How are emoji handled — one \u escape or two?
Two. Java strings are UTF-16, so any code point above U+FFFF is written as a surrogate pair: 🗼 (U+1F5FC) becomes \ud83d\uddfc, and Unescape reassembles the pair into the original character. Everything from U+007F upward is escaped this way — é is \u00e9, an em dash \u2014. Line breaks deliberately come out as \n rather than \u000a, because javac expands \u escapes before it tokenizes the file, and a \u000a would end the literal mid-string.
04Should I use a text block ("""…""") instead of escaping?
Text blocks (Java 15+) remove the need to escape most quotes and let line breaks stand as themselves, which makes multi-line HTML, SQL or JSON snippets far more readable in source. They don't remove escaping entirely, though: \uXXXX and \n/\t still work inside a text block exactly as in a regular literal, and a lone " or a run of three quotes still needs \" to avoid ending the block early.
05Why is \u000a dangerous in a Java string?
Because javac expands \u escapes before it tokenizes the source file, not while it reads the string literal. A \u000a inside a literal becomes an actual line break at that earlier pass, and an unescaped newline inside a regular string literal is a compile error — so this tool always writes a real newline as \n, never as \u000a, and Unescape treats the two as different inputs for the same reason.
Keep working
Related tools
JavaScript Escape
Escape / Unescape
.NET Escape
Escape / Unescape
JSON Escape
Escape / Unescape
JSON to Java
Paste a JSON or XML sample — the format is auto-detected — and get typed Java models with names, nesting and nullability inferred for you.
Python Escape
Escape / Unescape
YAML to Properties
Flatten application.yml into application.properties — dotted paths, Spring's key[0] list convention, and the ISO-8859-1 \uXXXX escaping Java's Properties loader expects.