String Escape / Unescape Tool
Escape or unescape a string for JavaScript/JSON, SQL or CSV.
Processed locally in your browser. Nothing you enter is uploaded or stored.
- Free — no signup, no account, no watermark
- Runs entirely in your browser — nothing is uploaded to a server
- Works on mobile, tablet and desktop
- Instant — results appear as soon as you enter your input
Why this is private
- Processed locally in your browser. Nothing you enter is uploaded or stored.
- Open your browser's DevTools → Network tab while using this tool — you won't see a request carrying your input, because it never leaves your device.
- Nothing you enter is uploaded to a server or shared with us — the processing happens entirely on your device.
Overview
Escapes or unescapes a string for safe inclusion in a JavaScript/JSON string literal, a SQL string literal, or a CSV field — three different escaping rules, one tool.
How to use it
- 1Pick what you're escaping for: JavaScript/JSON, SQL, or CSV.
- 2Choose Escape (raw text → safely-escaped form) or Unescape (escaped form → raw text).
- 3Paste your text — the result updates automatically.
Formula
JavaScript / JSON
Uses JSON.stringify, so \n \t \" \\ and Unicode escapes are produced exactly as a JS/JSON parser expects.
SQL
A literal ' is doubled to '' — the standard ANSI SQL string-literal escape, portable across MySQL, PostgreSQL, SQLite and SQL Server.
CSV
Per RFC 4180: a field containing a comma, quote or line break is wrapped in double quotes, with any internal " doubled to "".
Frequently asked questions
What people use it for
Embed a string with quotes in a JS template or JSON valueEscape a title or name containing apostrophes or quotes before hardcoding it.
Build a one-off SQL statement safelyEscape a value containing an apostrophe (e.g. "O'Brien") before dropping it into a query — though parameterized queries are safer for real applications.
Fix a CSV field with a comma or quote in itEscape a value like `Smith, John "Jr."` so it survives a CSV round-trip correctly.
Decode an escaped string from a log or configUnescape a `\n`/`\"`-laden string back to readable text.
Related guides
- How to read JSON with a tree viewerA tree viewer turns a wall of brackets into a structure you can expand, search and copy paths from. Here's how to use one effectively.
- JSON parse errors explained: 'Unexpected token', 'Expected comma or brace', and the restWhat each common JSON error message actually means, the usual cause, and how to find the spot fast using line and column.
- How to format JSON (and actually understand the errors)JSON looks like a JavaScript object but follows stricter rules. Here's what those rules are and how to read the errors when they're broken.
Related tools
All developer toolsJSON Viewer & FormatterView, format, validate, edit and beautify JSON with an interactive tree view, plus a shareable link.SQL FormatterFormat and indent SQL queries for readability.CSV FormatterClean up CSV formatting and convert between delimiters.HTML Entity EncoderEscape special characters into HTML entities — XML-safe, extended named, decimal or hex.
Ready to use String Escape / Unescape Tool?
String Escape / Unescape Tool