Zero Signup ToolsFree browser tools

Developer Tools

String Escape Tool

Escape and unescape strings for JavaScript, JSON, Python, HTML, XML, CSS, shell, SQL, C, Java, and C# literals in your browser. No upload, no signup.

Target language

Choose the string literal style your code uses. Each option formats the output the same way the language parser would expect to read it.

JavaScript
JSON
Python
HTML & XML
CSS
Shell
SQL
C / Java / C#

Output options

0 chars

JavaScript (double quotes) output

Wraps in ". Escapes \, ", and control characters. ${ stays literal.

Input chars

0

Output chars

0

Input UTF-8 bytes

0

Length change

0

How to use

  1. Pick the Escape direction (raw text in, language literal out) or Unescape (paste a literal, see the original characters). Use Swap to switch quickly.
  2. Choose your target language from the grouped list: JavaScript (double, single, template), JSON, Python (str, raw, bytes), HTML attribute, XML CDATA, CSS, shell (single, double, ANSI-C), SQL (ANSI or MySQL), or C, Java, C#.
  3. Paste your text on the left. Toggle Escape non-ASCII as \uXXXX if your output must stay ASCII-only, and Wrap output in quotes to get a complete pasteable literal.
  4. Read the formatted output on the right with character, byte, and length-change stats. Copy the result, or use Use as input to chain another conversion through a different target.

About this tool

String Escape Tool turns any text into a ready-to-paste string literal for nineteen popular targets, and turns the literal back into the original characters when the target's escape rules are unambiguous. The supported targets are JavaScript (double-quoted, single-quoted, and template literal), JSON (RFC 8259), Python str, Python raw r'...', Python bytes b'...', HTML attribute (double and single quote variants with entity encoding for &, <, >, and the active quote), XML CDATA sections (with safe splitting of any embedded ]]> sequence), CSS strings (with the \HHHHHH plus space hex escape), POSIX shell single-quoted, POSIX shell double-quoted (escaping $, backtick, backslash, and quote), bash ANSI-C quoting $'...', ANSI SQL (single-quote doubling, used by PostgreSQL, Oracle, SQL Server, and SQLite), MySQL backslash escaping (\\, \', \", \n, \r, \t, \0, \Z), and C, Java, and C# string literals. Each target uses the exact escape conventions a parser for that language expects so the output drops straight into source code or a SQL statement without any further fix-up. Two output options apply where they make sense: an Escape non-ASCII as \uXXXX toggle that forces every code point above U+007F into the language's Unicode escape form (handy when your build target only accepts ASCII source bytes), and a Wrap output in quotes toggle that adds the surrounding quote pair so the result is a complete literal you can paste between commas in an array or after an assignment. The unescape direction reads either a bare escaped body or a full quoted literal: the wrap pair is detected and stripped before parsing. Stats below show input and output character count, input UTF-8 byte count, and the length delta so you can see at a glance how much the escape grew or shrank the text. Useful for embedding multi-line text inside a JSON config field, building a SQL INSERT from an exported CSV, preparing a Python data fixture, dropping a quoted user-agent string into a curl one-liner, hardening an HTML attribute against an injection bug, decoding a stack-trace string back into the original message, or recovering the source text from a JSON-escaped log line. Everything runs in your browser with small per-target encoders. The text you paste here is never uploaded.

Free to use. Works in your browser. No signup, no login.

Related tools

You may also like

All tools
All toolsDeveloper Tools