Advertisements

headerup to 320x100 / 728x90

Java Escape / Unescape

Round-trip Java string literals — escape quotes, backslashes, newlines, and Unicode sequences

Mode:
Input
Loading editor...
Output

Output will appear here...

Advertisements

content bottomup to 300x250

What is Java Escape / Unescape

Last reviewed:

Java is a statically typed, object-oriented language used heavily in enterprise backends, Android development, and large-scale distributed systems.

Java Escape / Unescape converts arbitrary text into a Java-safe string literal or reverses the operation. It escapes non-ASCII characters as \uNNNN and handles \n, \t, \b, \f, \r, \", and \'.

It is a daily driver for Java developers embedding literals in code generators, writing test fixtures, parsing .properties files, or decoding minified Kotlin output.

Why use it

  • Embed user-provided strings in generated Java code.
  • Round-trip literals from .properties and .xml files.
  • Decode Unicode-escaped Java exceptions in logs.
  • Create safe unit-test fixtures with multi-line content.
  • Translate Kotlin escape sequences that follow the same rules.

Features

  • Round-trips Java, Kotlin, Scala string literals
  • Encodes non-ASCII as \uNNNN
  • Handles \n, \t, \b, \f, \r, \", \'
  • Java never leaves your machine
  • Perfect for .properties files

How to use Java Escape / Unescape

  1. Choose direction. Pick Escape or Unescape in the control bar.
  2. Paste content. Drop plain text (escape) or a Java literal (unescape).
  3. Run. Copy the result into your Java, Kotlin, or Scala source.

Example (before/after)

Raw text

"Hello" – world
Zürich

Java escaped

\"Hello\" \u2013 world\nZ\u00fcrich

Common errors

Surrogate pair output

Some tools emit invalid single \u escapes for astral chars.

Fix: This tool encodes BMP chars; beyond-BMP characters should use pre-split surrogate pairs.

Expected ASCII-only output

By default, non-ASCII is escaped as \uNNNN.

Fix: That's intentional — perfect for Java .properties files.

FAQ

Is the output ASCII-safe?

Yes — any character outside 0x20–0x7E is encoded as \uNNNN.

Does it work for Kotlin / Scala?

Yes — the same escape rules apply.

Does it preserve emoji?

Only within the Basic Multilingual Plane. Astral chars need explicit surrogate pairs.

How are Windows newlines handled?

\r\n is preserved on unescape; escape produces \r\n sequences.

Is data uploaded?

No — everything runs client-side.