Skip to content

Menu

String Escape/Unescape

Escape and unescape strings for JSON, HTML, URL, XML, CSV, and C/Java

Runs entirely in your browserText & DiffFree, no sign-up
Loading tool

01What is String Escape/Unescape?

Every format has its own idea of which characters are dangerous. A quote ends a JSON string, an ampersand starts an HTML entity, and a comma splits a CSV field. This tool converts text to and from the escaped form for seven formats. Pick Escape or Unescape, pick a format, and the result shows next to your input. JSON escaping calls the browser's own JSON.stringify and drops the outer quotes. You get exactly what RFC 8259 requires: quotes, backslashes and every control character below U+0020 become \", \\, \n, \t or \u0001 and so on. JSON unescaping reads \" \\ \/ \b \f \n \r \t and \uXXXX in a single pass. So an escaped backslash followed by n stays a real backslash and an n. HTML escaping turns & < > " and ' into entities. XML does the same but uses &apos; for the apostrophe. Unescaping decodes the five XML named entities (plus &nbsp; for HTML) and any numeric reference like &#39; or &#x27;. Other named entities, such as &copy;, pass through unchanged. URL mode uses encodeURIComponent and decodeURIComponent, which follow RFC 3986 percent-encoding with UTF-8 bytes. A stray % like in "100%" shows an error banner rather than a half-decoded string. CSV follows the quoting rule in RFC 4180. A field containing a comma, quote or line break gets wrapped in double quotes, and inner quotes are doubled. Unescape strips one pair of outer quotes and undoes the doubling. C/Java escapes backslashes, both quote types, \n \r \t and NUL. Its unescape also reads \a \b \f \v \?, octal like \101, hex like \x41 and \u00e9. SQL (MySQL) doubles single quotes and backslashes, matching MySQL's default string-literal rules. A quick worked example: escape O'Brien\path for MySQL and you get O''Brien\\path, ready to sit between single quotes. Some limits are worth stating plainly. HTML escaping makes text safe in element content and quoted attributes, not inside a script block or a javascript: URL. The SQL option is not a substitute for parameterized queries. CSV unescape handles one field, not a whole file. The conversion runs in the page's JavaScript, so the strings you paste stay in your browser tab.

Web and backend developers who need to move a string safely between JSON, HTML, URLs, CSV, C-style source and MySQL literals without hand-counting backslashes. The tool runs entirely in your browser, so your data never leaves your device.

02How to use String Escape/Unescape

  1. Choose the Escape or Unescape tab
  2. Under Format, select JSON, HTML, URL, XML, CSV, C/Java or SQL (MySQL)
  3. Paste your text into Input, or load one of the examples
  4. Read the result in the output panel; an error banner appears if the input can't be decoded
  5. Click Copy to put the result on your clipboard

03Worked examples

Input: Escape, JSON: He said "hi" + newline + tab + tab
Result: He said \"hi\"\n\ttab
Same as JSON.stringify, minus the surrounding quotes.
Input: Escape, HTML: <a href="x">Tom & 'Jerry'</a>
Result: &lt;a href=&quot;x&quot;&gt;Tom &amp; &#39;Jerry&#39;&lt;/a&gt;
The apostrophe becomes &#39;. The XML option would give &apos; instead.
Input: Escape, URL: a b&c=d/é
Result: a%20b%26c%3Dd%2F%C3%A9
Spaces become %20 (not +), / is encoded too, and é becomes its two UTF-8 bytes.
Input: Escape, CSV: 5" ruler, wood
Result: "5"" ruler, wood"
The comma triggers quoting, and the inch mark is doubled per RFC 4180.
Input: Unescape, C/Java: \x41\101\tB
Result: AA(tab)B
Hex \x41 and octal \101 are both the letter A. (tab) marks a real tab character.
Input: Unescape, HTML: &lt;b&gt; &#169; &copy;
Result: <b> © &copy;
Numeric references always decode, but &copy; is left as-is. Only amp, lt, gt, quot, apos and nbsp are known by name.

04Common use cases

  • Turning a Windows path or a multi-line error message into a valid JSON string value for a config file
  • Decoding &amp;, &lt; and &#x27; in text scraped from a web page or exported from a CMS
  • Reading a log line full of \n and \u00e9 escapes as normal text
  • Escaping a CSV field that contains commas, quotes or line breaks before pasting it into a spreadsheet export
  • Percent-encoding a query parameter value that contains &, = or / before adding it to a URL
  • Preparing a quoted MySQL literal by hand for a one-off query in a console

05Tips

  • A single backslash in a Windows path breaks JSON parsing. Escape C:\new\file here and you get C:\\new\\file, so \n is no longer read as a newline.
  • Unescape only once. Running HTML unescape twice turns a literal &amp;lt; into <, which changes the text.
  • URL unescape doesn't turn + into a space. That is a form-encoding rule, so a+b%20c decodes to a+b c.
  • The SQL option's backslash doubling is MySQL-specific. PostgreSQL with standard_conforming_strings and SQL Server treat backslashes literally, so don't use this output there.
  • Use the XML option for XML attributes that might be parsed by older tools, since it emits &apos; instead of the HTML-style &#39;.

06Related concepts

Character encoding, XSS prevention, Unicode escapes, HTML entities.

Frequently Asked Questions

What is String Escape/Unescape?

String Escape/Unescape is a free, browser-based developer tool on AIDToolStack. Escape and unescape strings for JSON, HTML, URL, XML, CSV, and C/Java It requires no installation or sign-up and works entirely in your browser.

Is String Escape/Unescape free to use?

Yes. No sign-up, no fees and no usage cap.

Does String Escape/Unescape store my data?

No. It runs in your browser; nothing is uploaded.

Related Tools

Reviews and commentsShow

Reviews

Sign in to leave a review.

Loading reviews…

Comments

Sign in to leave a comment.

Loading comments…

What changed in AI dev tools, once a month

Renames, shutdowns, pricing changes and new MCP setups, each with a source.

Subscribe