Text

String Escape

Escape text into a string literal (quotes, backslash, control characters) for pasting into code, or unescape it back.

Quote style

                    

To put text containing quotes, line breaks, or backslashes inside a string literal in code, those characters need escaping — otherwise they'll end the string early or get misinterpreted. This tool escapes and unescapes text for a specific syntax.

How to use it

Common uses

Things to keep in mind

The same character (a double quote, for example) is escaped differently depending on context — a JS string, JSON, and a shell each have their own syntax and their own set of special characters.

Double-escaping (escaping already-escaped text) is a common mistake when passing data through multiple layers, like JSON nested inside a shell command.

Article about this tool: String Escape: why the same text needs escaping differently

Frequently asked questions

What exactly does escaping do?

It turns quotes, backslashes, and control characters (like line breaks or tabs) into valid escape sequences within a string literal, so the text can be pasted as-is into source code.

What are the quote style and unicode options for?

The quote style (double, single, or backtick) determines which character is escaped so it doesn't break the string, and the \uXXXX option converts non-ASCII characters into escaped unicode sequences rather than leaving them as-is.

Is the pasted text sent to a server?

No, escaping and unescaping run entirely in the browser via JavaScript, no data is sent online.

What if the text passes through several contexts in a row?

Escaping needs to happen in the right order: first for the inner context (say, JSON), then for the outer one (say, the shell command that this JSON gets inserted into). Getting the order wrong or skipping a level is a common reason a "properly escaped" string still breaks in practice.

Why is the same quote character escaped differently in different contexts?

Each context (a JS string, JSON, shell, regex) has its own syntax with its own set of special characters and its own way of escaping them — so correct escaping depends on where exactly the text is being inserted, not on the text itself.

Articles: Text

Case Converter: why different naming styles exist

Why one project writes variables in camelCase but files in kebab-case, and where these rules came from.

Text Diff: how algorithms find the difference between two texts

How a diff algorithm finds the minimal set of changes between two versions of a text.

Regular expressions: basic syntax and common patterns

How to read a regular expression, and how greedy matching differs from lazy matching.

Sorting and deduplicating lines: why it matters

Why numeric sorting putting "10" before "9" is a mistake, and how to avoid it.

CRLF vs LF: why line ending characters still matter

Why a file written on Windows can show as "entirely changed" in git on Linux.

Counting characters and words: why it's not always trivial

Why an emoji or an accented character can count as several characters at once.

Lorem Ipsum: where the placeholder text came from and why it exists

Why designers deliberately use "nonsense" text instead of real content in mockups.

Slugify: turning arbitrary text into a URL

How a title like "Hello, World!" turns into a URL-safe string like hello-world.

Markdown: why plain-text syntax beat rich text editors

Why developers choose to write documentation in Markdown instead of a rich text editor.

Whitespace and invisible characters: the hidden cause of weird bugs

Why two strings that look identical can fail to match because of an invisible character.

Text Reverse: why "reversing text" is harder than it sounds

Why a naive string reversal can turn an emoji into unusable bytes.

Text frequency analysis: why count how often words repeat

How letter frequency in ciphertext helps crack the simplest substitution ciphers.