Escape Character Online
Escape quotes, newlines and control characters with backslashes.
Encoders & Decoders Runs in your browser
What is escaping characters online?
Turns characters that would break a string literal into their backslash forms: a real newline becomes \n, a tab becomes \t, a double quote becomes \" and a lone backslash doubles to \\. Control characters with no short escape come out as four-digit \u sequences, so nothing invisible survives. The whole input is converted in one pass, ready to sit inside quotes.
How to use the Escape Character Online
- 1 Paste text containing newlines, tabs, quotes or control characters.
- 2 Read the escaped form as it is produced.
- 3 Rare control characters come out as four-digit \u sequences.
- 4 Move the escaped text into your string literal.
What you can use it for
- Embedding multi-line text in source code.
- Building a JSON or JavaScript string by hand.
- Escaping quotes for a config value.
- Making control characters visible for debugging.
Frequently asked questions
Which characters gain a backslash?
Both quote styles, the backslash itself, and control characters including newline, carriage return, tab, backspace and form feed, using their short forms where those exist.
What form do obscure control characters take?
A \u escape with four hex digits, such as \u001b for the escape character, so the output contains nothing unprintable.
How do I undo this later?
Paste the escaped result into the unescape string tool. It reverses every sequence this tool produces, including the \u forms.
Related tools
More Encoders & Decoders
More tools like this:
All Encoders & Decoders