Format Code Now
/

CSV Escape and Unescape

ED-25

Paste one value to wrap it in quotes the way RFC 4180 describes, or paste a quoted CSV value to get the plain text back. Commas, quotes and line breaks are all covered.

Runs in your browser. Nothing is uploaded.

One value

Result

How to use it

  1. Pick the delimiter your file uses: comma, semicolon, tab or pipe.
  2. Paste the value into the input box.
  3. Click Escape to make it safe for a CSV field, or Unescape to read a quoted field.
  4. Copy the result, or download it as a .txt file.

When a value gets quotes

RFC 4180 says a field that contains the delimiter, a double quote or a line break must be enclosed in double quotes, and that any double quote inside must be doubled. So say "hi" becomes "say ""hi""". A value without any of those is returned as it is. You can tick Always add quotes, and the tool also quotes values with spaces at either end unless you turn that off, which protects them from being trimmed by some readers.

What Unescape checks

If the text starts with a double quote, it reads up to the closing quote, turning doubled quotes into single ones. A missing closing quote or text after the closing quote is an error with the position. If the text does not start with a quote, it must not hold a quote, line break or the chosen delimiter, because then it would be more than one field.

One value, not a file

The tool handles a single value at a time. It does not split rows or columns and does not read a whole CSV file. Use it when you build a line by hand, fill a template, or need to see what a tricky cell should look like. A trailing line break in the input of Unescape is ignored. Other rules, such as escaping formulas for spreadsheets, are outside what it does.

Error messages and what to do

MessageWhat it meansFix
closing double quote is missingThe value starts with a quote that is never closed.Add the closing quote, or double any quote that is part of the text.
Text after the closing quoteSomething follows the quote that ended the value, or a quote inside is not doubled.Write each inner quote as two quotes.
is outside quotes, so this is more than one valueThe unquoted text contains the chosen delimiter, so it is several fields.Quote the value, or select the delimiter your data really uses.
inside an unquoted valueA double quote appears in a value that does not start with one.Wrap the value in quotes and double the inner quotes.

Questions people ask

How do I escape a comma in CSV?

Put the whole value in double quotes, for example "Smith, John". The comma inside the quotes is then part of the value and not a separator. Paste the value here and click Escape to have it done for you.

How do I escape double quotes in CSV?

Write each double quote as two double quotes and wrap the value in quotes, so say "hi" becomes "say ""hi""". A backslash is not the escape character in RFC 4180 CSV, even though some programs accept it.

How do I put a line break inside a CSV cell?

Wrap the value in double quotes and keep the line break inside them. The tool does this automatically when the text contains a line break. Not every reader accepts multi-line fields, so test with the program you will use.

Can I use a semicolon or tab instead of a comma?

Yes. Choose the delimiter and the tool will quote values that contain that character. The same rule applies to the quote character, which stays the double quote. Comma is no longer special in that case.

What does Unescape do with the quotes?

It removes the outer pair of quotes and turns each doubled quote back into one. It stops with an error if the closing quote is missing or text follows it. It works on one field, not a whole row of fields.

Is my value uploaded?

No. The tool runs in your browser, so the value you paste is not sent to a server, which matters when the cell holds customer data. There is no sign-up, and it makes no network calls.

About this tool

Works on a single value, not a whole file. Escape wraps the value in double quotes and doubles any double quote inside it when the value contains the chosen delimiter, a double quote or a line break, as RFC 4180 describes; other values are returned unchanged. The option to quote values with spaces at either end goes beyond the RFC but protects them from being trimmed by some readers. Unescape removes the outer quotes and turns doubled quotes back into one. It reports a missing closing quote, text after it, or an unquoted value that holds the delimiter, a quote or a line break. To split a whole CSV file use the CSV converters on this site.

Format Code Now: free, no ads, no accounts. Your input stays in your browser.