JSON Escape & Unescape (plus XML, CSV and SQL)

Escape or unescape text for JSON/JavaScript strings, XML, CSV and SQL. Free, instant, private.

50 free uses every 24 hoursUnlimited with Pro →

Private by design — your data stays on your deviceEverything runs right here in your browser. What you type is not sent to our server and is not stored.
  • Runs in your browser
  • Not stored
  • No sign-up

This tool does a JSON escape for you: it turns text with quotes, line breaks and special characters into a string that is safe inside JSON, XML, CSV or SQL. It also works in reverse, so you can turn escaped text back into normal, readable text. It is built for developers, analysts and anyone who has pasted text into a file and watched it break.

How do you escape or unescape a string?

The tool has three steps, and each one matches what you see on the page.

  1. Choose Escape or Unescape, then pick the format: JSON/JavaScript, XML, CSV or SQL.
  2. Paste your text into the input box.
  3. Copy the result and use it in your code, file or query.
How to use the String Escape / Unescape on OneHubTools: 3 steps with a real screenshot of the tool
How to use the String Escape / Unescape, step by step.

This tool pairs well with the HTML Entity Encoder / Decoder. If you do this kind of job often, the JSON Formatter & Validator and the Chmod Calculator can save you time too.

Everything runs in your browser. Your text is not uploaded anywhere, which matters when you are working with logs, customer data or API payloads. The tool is free to use.

What does escaping actually do?

Every format has characters that mean something special. A double quote ends a JSON string. An ampersand starts an XML entity. A comma splits a CSV field. A single quote closes a SQL string. Escaping marks those characters as plain text, so the parser reads them as content and not as syntax.

Unescaping does the opposite. It takes the marked-up version, such as \n or &, and gives you the original characters back.

Result from the String Escape / Unescape on OneHubTools
What the String Escape / Unescape gives you.

Escape rules at a glance

These are the standard conventions for each format. The examples show the idea, so use the tool for the exact output.

FormatPlain textEscaped
JSON / JavaScriptHe said "hi"He said \"hi\"
XML5 < 6 & 75 &lt; 6 &amp; 7
CSV5" pipe, steel"5"" pipe, steel"
SQLO'BrienO''Brien

What is a JSON escape tool good for?

  • Putting text inside a JSON value. Paste a paragraph with quotes and line breaks, and get a string you can drop into a request body or config file.
  • Reading escaped API responses. Use JSON unescape on a string full of backslashes to see the real text.
  • Preparing XML. Escape text that contains ampersands or angle brackets before it goes into a feed or markup.
  • Cleaning up CSV fields. Handle values with commas, quotes or line breaks so they do not shift columns.
  • Writing SQL by hand. Escape a name like O'Brien so a quick query or test script does not fail on the apostrophe.

Tips for better results

  • Pick the format first. The same character is handled differently in each format. A quote in JSON is not treated like a quote in CSV.
  • Escape only the value, not the whole document. If you paste a full JSON object, the structural quotes will be escaped too and the object will stop being valid JSON.
  • Escape once. Running text through Escape twice adds a second layer of backslashes or entities. If the result looks cluttered, you have probably doubled up.
  • Check line breaks. In JSON, a real new line becomes \n. If your output sits on one long line, that is expected.
  • Test small samples first. Try a short string with the awkward characters before you process a large block.

Common problems and how to fix them

My JSON still will not parse

Look for an unescaped quote or backslash outside the part you converted. Also check for a trailing comma or a missing bracket. Escaping fixes characters inside a string, not the structure around it.

I see backslashes everywhere

The text was probably escaped more than once. Switch to Unescape and run it a single time, then check whether it reads normally.

My CSV columns are shifted

A field with a comma or line break needs to be wrapped in double quotes, and any inner quotes doubled. Escape the field in CSV mode and paste it back in.

A SQL query breaks on an apostrophe

The single quote closed your string early. Escape the value in SQL mode. For anything that runs in production, parameterised queries are the safer habit, and escaping by hand is best kept for quick, one-off work.

Escape or unescape: which one do you need?

Choose Escape when you are putting raw text into a format. Choose Unescape when you are reading text that already came out of one. If you can see sequences like \", \n or &lt; in text meant for people, you need Unescape.

Limits and specs

PriceFree
Free use50 uses every 24 hours — shared with 178 other tools in the “Basic tools” group
Where it runsIn your browser
Sign-upNot needed
Muhammad Shahwaiz Gillani
Maintained and reviewed by Muhammad Shahwaiz GillaniSoftware engineer and founder of OneHubTools · Last reviewed

How we checked it: We tested it in Chrome with real code and data, including edge cases such as empty input and very long values.

Learn more

According to json.org, JSON is a lightweight data-interchange format that is easy for humans to read and easy for machines to parse, and it has been in wide use for more than 20 years.

Spotted a mistake or the tool did not work for you? Tell us and we will fix it.

Rate this tool

Ratings come only from signed-in users, so every rating is verified.

Only signed-in users can rate tools, so every rating shows a ✔ Verified badge.Sign in to rate

Frequently asked questions

What does JSON escape mean?

JSON escape means replacing characters that would break a JSON string, such as double quotes, backslashes and line breaks, with safe sequences like \" and \n. The parser then reads them as ordinary text.

How do I unescape a JSON string?

Choose Unescape, select the JSON/JavaScript format, and paste your string. The tool turns sequences like \n and \" back into real line breaks and quotes, and you can copy the result.

Which formats does this tool support?

It supports four formats: JSON/JavaScript strings, XML, CSV and SQL. Each one works in both directions, so you can escape or unescape.

Is my text uploaded or stored?

No. The tool processes your text in your browser, so nothing is uploaded. That makes it a reasonable choice for logs and other private data.

Why do I get double backslashes after escaping?

Double backslashes usually mean the text was escaped twice, or it already contained backslashes that needed escaping. Run Unescape once and check the result.

Is the string escape tool free?

Yes, it is free to use, with no sign-up needed. Paste your text, choose a format and copy the result.