About this tool
Escape a string for JSON/code (quotes, backslashes, newlines) or unescape it.
The String Escape Tool converts raw text into a JSON-safe string literal — escaping double quotes as \", backslashes as \\, newlines as \n, tabs as \t and other control characters as \u sequences — and reverses the process on demand. It uses the same rules as JavaScript's JSON.stringify and JSON.parse, so the output is exactly what a JSON parser expects. Paste text in, pick Escape or Unescape, and copy the result straight into your code or config file.
Open String Escape Tool on AltFTool — it loads instantly in your browser.
Paste your code or data sample into the workspace.
Pick the format, conversion, or analysis you need.
Copy the polished result straight back into your project.
Escape and unescape share one parser, so text that goes through both comes back byte-for-byte identical.
Tabs, carriage returns, form feeds and non-printables become \t, \r, \f and \uXXXX instead of silently breaking the file.
An unescape on a malformed sequence reports an invalid escaped string rather than returning half-decoded text.
Seven characters get short escapes — double quote (\"), backslash (\\), backspace (\b), form feed (\f), newline (\n), carriage return (\r) and tab (\t) — and every other control character below U+0020 becomes a six-character \u00XX sequence. Ordinary letters, digits, punctuation and Unicode text pass through unchanged.
No. JSON strings are delimited by double quotes only, so an apostrophe or single quote is an ordinary character and is left alone. If you are pasting into a single-quoted JavaScript or Python literal, you will need to escape it yourself for that language.
The outer pair of double quotes is stripped so you get just the string body, ready to paste between quotes you already typed. Add them back if you need a complete JSON value rather than a fragment.
Usually yes. C, C++, Java, JavaScript, Go and C# share the same backslash escapes for quotes, newlines and tabs, so the output pastes in cleanly; the main difference is Unicode, where some languages expect \uXXXX pairs or \U00XXXXXX for characters above U+FFFF.