Skip to main content
Encoders100% FreeInstant

String Escape and Unescape for JSON, JS, HTML, Regex and SQL

This free tool escapes and unescapes text for JSON, JavaScript, HTML, regular expressions, SQL and CSV. It handles quotes, backslashes, newlines and special characters.

By Debmedia Technologies LLP · Kolkata, India · Updated

What Is It and When Do You Need It?

Escaping makes special characters safe to put inside a string, a pattern or a document. Each language has its own rules, so a quote that works in one place breaks another.

Choose the format and the direction, paste your text and copy the result.

How to Use This Tool

  1. Paste your text.
  2. Choose the format.
  3. Choose escape or unescape.
  4. Press Convert.

How the Calculation Works

JSON and JavaScript escape backslashes, quotes and control characters with backslash sequences. HTML replaces & < > " and ' with entities. Regex puts a backslash before every special character. SQL doubles single quotes. CSV wraps the cell in quotes and doubles inner quotes.

Worked Example

The text He said "hi" followed by a line break becomes He said \"hi\"\n in JSON mode.

Common Uses

  • Putting text into JSON or code.
  • Building safe regex patterns.
  • Preparing CSV cells.
  • Reading escaped logs.

Tips and Common Mistakes

  • Escape once only: escaping twice doubles the backslashes.
  • Unescaping needs well-formed input.
  • For URLs, use the URL encoder in DebText.
  • When you put escaped text inside a code file, remember that the surrounding quotes belong to the language, so add the right kind of quote around the result yourself.

Next, you may need the Base32 encoder, query string parser, SQL IN clause generator, ASCII table.

Everything runs in your browser. Nothing you type is uploaded, stored or sent to any outside service.

Frequently Asked Questions

Characters such as quotes, backslashes and angle brackets have special meaning. Escaping tells the parser to treat them as plain text.
It escapes quotes, backslashes, tabs, new lines and control characters the way JSON requires, without the surrounding quotes.
The five characters & < > " and ', turning them into entities.
It helps, but you should also use safe APIs, parameterised queries and output encoding in your framework.

Disclaimer: results are calculated in your browser from the numbers you enter. Check important results before you rely on them for money, health, safety or legal decisions.