CSV Field Escaper/Unescaper

Wrap and escape fields with commas, quotes, or newlines in CSV

Escape and unescape CSV fields per RFC 4180: wrap fields containing a comma, double quote, or newline in quotes and double any embedded quotes. Choose comma, semicolon, or tab delimiters. Runs entirely in your browser. It runs free in your browser on Gera Tools, with nothing uploaded.

Last updated Source: Gera Tools

When does a CSV field need quoting?

Per RFC 4180, a field must be wrapped in double quotes if it contains the delimiter, a double quote, or a line break. Fields without any of those characters are left bare. This tool quotes only when required, keeping output minimal and readable.

CSV looks simple until a value contains a comma, a quote, or a line break. This tool applies the RFC 4180 rules to escape a single field so it round-trips correctly, and unescapes a quoted field back to its raw value.

How it works

A field is quoted only when it must be, and embedded quotes are doubled:

needs quoting if field contains: delimiter, double quote, or newline
escape: wrap in " ... " and replace every " with ""
"plain"            -> plain            (no special chars, left bare)
a,b                -> "a,b"            (comma forces quoting)
6" pipe            -> "6"" pipe"       (quote doubled)
line1\nline2       -> "line1\nline2"   (newline forces quoting)

Unescaping detects a field wrapped in double quotes, strips the outer pair, and collapses every "" back to a single ".

When do you need to escape a CSV field?

Most of the time you don’t — if a field contains only letters, numbers, and punctuation other than the delimiter, no quoting is required. You need to escape when the value includes:

  • The delimiter character — a comma (or semicolon, or tab) inside the value would split the row at the wrong place.
  • A double quote — the parser uses " to start and end quoted fields, so a literal " inside must be doubled to "".
  • A line break — a bare \n or \r\n would end the CSV record mid-field; quoting the field keeps the line break as part of the value (useful for multi-line addresses or notes).

Practical examples

Raw valueEscaped (comma delimiter)Why
plain textplain textNo special characters, no quoting needed
London, UK"London, UK"Comma forces quoting
6" pipe"6"" pipe"Quote is doubled inside quoted field
Line 1\nLine 2"Line 1\nLine 2"Newline forces quoting
{a: 1}{a: 1}Curly braces are not special in CSV

Delimiter choice and regional conventions

The tool supports comma, semicolon, and tab delimiters:

  • Comma — the default in most English-language tools.
  • Semicolon — standard in many European countries where the comma is the decimal separator (Germany, France, the Netherlands). Excel on a German system exports with semicolons by default.
  • Tab — produces TSV; tabs in values are very rare in practice, making quoting unnecessary in most files.

The formula injection caveat

RFC 4180 escaping makes a field parse correctly as a data value. It does not prevent formula injection in spreadsheet tools. A value beginning with =, +, -, or @ is treated as a formula by Excel and Google Sheets when the file is opened, regardless of quoting. For CSV destined for spreadsheets, prefix such values with a single quote or a space, or configure the spreadsheet to import the column as text.

Quote only when necessary — over-quoting every field is legal but bloats the file and hurts readability. All processing runs in your browser; nothing is uploaded.