CSV escape rules (RFC 4180)
CSV looks simple until a value contains the delimiter, a quote or a line break. A CSV escape wraps such a field in double quotes and doubles every quote inside it, so that spreadsheet programs and CSV parsers read it back as one value. This tool applies those rules to whatever you paste.
A field is quoted when it contains any of the following:
- The selected delimiter (comma, semicolon, tab or pipe).
- A double quote — each
"inside the value becomes"". - A line feed or carriage return, so multi-line values stay in one field.
- Leading or trailing whitespace, which some parsers would otherwise trim.
Values without any of these are returned unchanged, which keeps files small and readable.
Example
Input:
Widget, large "XL" editionOutput:
"Widget, large ""XL"" edition"With the Semicolon delimiter, common in European versions of Excel, a;b becomes "a;b" while a comma no longer triggers quoting.
Why the delimiter option matters
Quoting depends on which character separates the columns. A value with a comma must be quoted in a comma-separated file, but is harmless in a tab-separated one. Pick the delimiter of the file you are editing so only the necessary fields get quoted.
Quoting also protects values that contain the delimiter by accident, such as prices with a decimal comma (“3,50”) in a comma-separated file, or pipe characters inside free-text notes in a pipe-delimited export.
This “quote only when needed” behaviour matches Python’s csv.writer with its default QUOTE_MINIMAL setting and what Excel and Google Sheets write when they export. Some tools quote every field instead; both styles are valid and read back identically.
What CSV escaping does not cover
Escaping keeps the file structure intact, but it does not stop spreadsheet programs from interpreting a value. A field that starts with =, +, - or @ may be treated as a formula when the file is opened in Excel or similar apps (known as CSV or formula injection). If you export user-supplied data, prefix such values with a single quote or a space according to your application’s policy.
To build a full CSV file from structured data, try JSON to CSV, and use CSV Unescape to reverse a single field. Everything runs in your browser.