String Escape and Unescape Tool

Escape supported string contexts, select example settings and download the converted text.

On-device No sign-up Free to use

Convert string controls

Showing an example. Edit to see your own.

?

Escape accepts up to 50,000 characters. Unescape accepts formatted text up to 300,002 characters and returns at most 50,000. NUL is refused in every format; JavaScript uses a JSON-compatible double-quoted subset.

?

JavaScript strings use a JSON-compatible double-quoted subset, not every JavaScript literal form. Each format only formats text; it does not make arbitrary SQL queries or shell commands safe.

Processed in your browser. Your inputs stay on this device.

Result

Showing an example.

Quote an apostrophe and double quotes as one POSIX shell word, without running a command.

Escaped text as a POSIX shell single-quoted word. This formatting does not make arbitrary SQL queries or shell commands safe.
'can'\''t say "yes"'

Loading the tool. Your result will appear here.

https://usefreetools.net/string-escape-unescape · 20 November 2026

Was this helpful?

How to use String Escape and Unescape Tool

  1. Choose the target string context and Escape or Unescape. The JSON string and Literal pattern buttons choose their named escape mode.
  2. Paste literal text for escaping, or one complete representation in the selected grammar for unescaping. JavaScript mode accepts only the documented JSON-compatible double-quoted subset.
  3. Check quotes, backslashes and line breaks, then copy the result or download formatted-string.txt. Switching grammar changes how the value is represented.

Example: String Escape and Unescape Tool

Quote an apostrophe and double quotes as one POSIX shell word, without running a command.

You add
Action: escape; Target format: posix-shell; Text or formatted string: can't say "yes"
You get
Escaped text as a POSIX shell single-quoted word. This formatting does not make arbitrary SQL queries or shell commands safe. 'can'\''t say "yes"'

Options

JSON and JavaScript strings
Both use one complete double-quoted JSON-compatible literal. JavaScript single quotes, template literals, \x and \v escapes are outside this subset.
SQL, shell and CSV forms
SQL-standard strings double internal apostrophes; CSV fields double internal double quotes. POSIX shell mode quotes one word and represents an internal apostrophe with its exact supported quote sequence. These formats do not validate a surrounding query, command or spreadsheet formula.
Literal regex text
Regex mode escapes text so its metacharacters can be matched literally. Unescape accepts that supported literal-text representation, not an arbitrary regex expression. The page does not run a pattern.

Supported inputs and limits

  • Escape accepts up to 50,000 raw characters;
  • Unescape accepts up to 300,002 formatted characters and returns at most 50,000.
  • NUL is refused in every mode.
  • Contexts are JSON strings, a JSON-compatible JavaScript double-quoted subset, standard SQL single-quoted literals, POSIX shell words, CSV fields and JavaScript regular-expression literal text.
  • Only the selected documented grammar is accepted.
More details

No query or command is executed and no pattern is matched.

SQL quoting is not a substitute for parameters; shell word quoting does not validate a surrounding command;

CSV quoting alone does not neutralise spreadsheet formulas.

Where your input is processed

This tool does not upload your inputs. See the limits for anything saved on your device.

A quoted value has a boundary

The surrounding quotes and the characters inside them work together. A backslash copied from one context can have another meaning in a different grammar. Use a round trip to inspect the intended literal text, and keep parsing or execution outside this conversion page.

Questions about String Escape and Unescape Tool

Why do SQL and JavaScript quotes look different?

They follow different string grammars. The SQL mode uses the documented standard single-quoted literal form; JavaScript and JSON have their own escape rules.

Does shell quoting make a whole command safe?

It quotes one supported shell word. It does not validate a command, its arguments or the program being called. Do not treat a recovered value as something this page has approved to execute.

Can I use this instead of query parameters?

SQL literal quoting is useful for inspecting text, but application database queries should use their parameter interface. A quoted string does not validate the surrounding query.

Why is an escape sequence rejected?

JavaScript mode accepts a JSON-compatible double-quoted subset, so forms such as single quotes, \x escapes or \v are refused. Other modes also require their named quoted form; check the selected context before unescaping.

Does quoting a CSV field neutralise a formula?

CSV mode quotes separators, quotes and line breaks. Spreadsheet apps may still treat a formula-leading cell as a formula. Use a data-only import or an explicit formula-safe export when that distinction matters.

Page updated · Project managed by Tony Hines · Report a problem with String Escape and Unescape Tool