TextToolboxTextToolbox

Swap Columns Tool

Exchange two raw fields while checking marker and field-boundary identity before export.

Built by Saurabh Kumar

Quick Answer

Exchange two selected fields, including the header, while retaining their raw spelling and record endings. Candidate output is checked for boundary and initial-marker ambiguity before Copy or Download. Invalid or ambiguous results stay blocked with editable input.

Swap Columns Tool

Choose Quoted mode for CSV-style fields or Literal mode for exact separators. Values are not trimmed. A missing selected column blocks the output with its record number.

Delimiter presets:

Tab inserts an actual tab. Typing backslash-t is a literal two-character delimiter and needs Literal mode. Input limit: 1,000,000 UTF-16 code units and 20,000 records.

Exchanging Two Columns, Header Included

Exchange two positions while keeping the rest of each record. If an import template expects ID before Name, swap those columns rather than extracting a field and rebuilding the table. The header moves with its values. This tool does not infer types, trim spaces or change identifiers to numbers.

Choosing a Mode and Two Column Numbers

  1. Paste a small representative dataset, or use Sample.
  2. Choose Quoted mode for CSV-style quoting, or Literal mode for an exact separator without quote interpretation. Use Tab for TSV.
  3. Set Column A and Column B to positive whole-number positions, starting at 1.
  4. Review complete output and any error before Copy or Download. If Copy fails, select the output manually. Clear restores empty input and default settings.

How Raw Fields Are Swapped and Rechecked

The parser keeps each field's raw spelling, including quotes and spaces, each record ending and an initial U+FEFF marker. Swapping reorders those strings; it does not decode and rewrite every field. Quoted mode handles doubled quotes and quoted newlines. Literal mode treats quotes as data and matches a nonempty exact separator.

Before showing output, the tool reparses the candidate and checks its marker, record boundaries/endings and intended raw field order. A moved value can otherwise form a delimiter across a boundary or expose U+FEFF as an initial marker. An ambiguous candidate is blocked instead of being silently escaped or partially exported. Accepted swaps retain the intended field identities; applying the same pair again restores the received source string.

Six Swaps: Four Accepted, Two Blocked

Successful outputs use JSON string notation so line endings and quotes are visible. U+FEFF is shown as \uFEFF rather than an invisible character. Blocked examples produce no exportable output.

Successful raw swaps and boundary cases that are blocked
Input and settingsComplete outputWhat to check
"Name,ID\r\n\"Doe, Jr.\",00123". Quoted comma, columns 1/2"ID,Name\r\n00123,\"Doe, Jr.\""Header and raw quoted name move together
"\uFEFF\"a\",b\r\nc,d\n". Quoted comma, columns 1/2"\uFEFFb,\"a\"\r\nd,c\n"Original marker, quotes and mixed record endings survive
"a::b\r\nc::d". Literal ::, columns 1/2"b::a\r\nd::c"A safe multi-character separator remains supported
A,B. Quoted comma, columns 1/1"A,B"Same-column selection is unchanged but still validates the column
A|||. Literal ||, columns 1/2No output: field-boundary errorA moved pipe would change the parsed fields
"A,\uFEFFB". Quoted comma, columns 1/2No output: initial-marker errorQuote the marker-bearing value in Quoted mode or choose another order

When to Swap, and What to Do When It Is Blocked

Use this for a known two-column exchange, including the header. If you only want one field, choose Extract Column. Keep a copy of the source and check the target import requirements before replacing an export.

Choose a recovery step without changing field meaning silently
SituationNext stepLimit
Quoted names or multiline notesQuoted mode with the source delimiterOne UTF-16 delimiter unit, excluding quotes/line breaks; no type inference
Exact multi-character separatorLiteral mode, then inspect the accepted resultBoundary-changing permutations are rejected
U+FEFF payload would become a markerQuote that source value in Quoted mode or keep its current positionThe tool does not add quoting behind your back
A row lacks a selected fieldCorrect that source record or change the selected columnsNo partially swapped batch is exported

Limits, Downloads and Browser Behavior

A same-column swap still checks that the field exists. Headers are data and move too; they are not guessed or skipped. Blank records remain records, and a final line ending does not create an extra row. Quoted mode rejects malformed quoting, including unexpected text after a closing quote. Literal mode is appropriate only when quotes should be ordinary characters.

Limits are 1,000,000 UTF-16 code units and 20,000 records. Incomplete Unicode in source or delimiter blocks output. A supplementary-character delimiter needs Literal mode because it uses two units. Typing backslash-t is not a tab. Error messages leave the source editable, and Copy/Download stay disabled until a valid result exists.

Download saves swapped-columns.txt; it does not validate a spreadsheet schema or make formulas inert. Swapping runs in your browser on the text you paste, not on the bytes of an original file; the Privacy Policy covers site-wide data handling. Browser clipboard, textarea and receiving-file behavior need their own checks.

Try a quoted delimiter, an empty field, meaningful spaces and mixed record endings in a small fixture. Compare an accepted result with the source, including header order and marker placement. Informational RFC 4180 explains common CSV quoting; the alternative separators and line endings here are explicit extensions.