Java String Escape screenshot

Java String Escape

Escape text for a Java string literal: quotes, backslashes, control characters, and \uXXXX for non-ASCII.

Privacy First
0 Runs
Updated 2026-11-06
No upload
Instant
No signup

What escaping a Java string does

Backslash, double quote and the control characters become their Java escapes, and anything outside printable ASCII becomes a four-digit \u escape. Java source is Unicode, so that last part is a choice rather than a requirement: a literal outside ASCII is unreadable in a diff and breaks when a file is saved in the wrong encoding, which is why the escaped form is what survives a copy from a terminal. The output is the body of the literal, so put it between the quotes yourself.

How to use it

Java String Escape: paste the text into the box above, and press Run to get the Java string body below.

Worked example

Input:

He said "hi"
Then left	(café)

Output:

He said \"hi\"\nThen left\t(caf\u00e9)

Why it runs in your browser

The conversion happens on this page with JavaScript. Your input is not posted to a server, so it works offline after the page loads and nothing is retained anywhere. The page reads text and returns Java string body; reloading the page discards both.

Backslash, double quote and the control characters become their Java escapes, and anything outside printable ASCII becomes a four-digit \u escape. Java source is Unicode, so that last part is a choice rather than a requirement: a literal outside ASCII is unreadable in a diff and breaks when a file is saved in the wrong encoding, which is why the escaped form is what survives a copy from a terminal. The output is the body of the literal, so put it between the quotes yourself.

Escape text for a Java string literal: quotes, backslashes, control characters, and \uXXXX for non-ASCII.

How to use it

Java String Escape: paste the text into the box above, and press Run to get the Java string body below.

Why it runs in your browser

The conversion happens on this page with JavaScript. Your input is not posted to a server, so it works offline after the page loads and nothing is retained anywhere. The page reads text and returns Java string body; reloading the page discards both.

What to Expect

Best for

  • Converting text to Java string body when the data is already on screen.

What this tool keeps

  • Your input is not posted to a server, so it works offline after the page loads and nothing is retained anywhere.

Sample input

He said "hi" Then left (café)

Sample output

He said \"hi\"\nThen left\t(caf\u00e9)

Frequently asked questions

How do I use the java string escape?

Java String Escape: paste the text into the box above, and press Run to get the Java string body below.

Is my input uploaded?

No. The text is parsed on this page with JavaScript and is never posted to a server.

Is there a size limit?

Yes: 5 MB per run. Larger input is refused with a message rather than freezing the tab.

Developer program

Build custom tools for your store

Join the SDK program to create useful ecommerce utilities for your store.