TextToolboxTextToolbox

Swap Columns Tool

Swap two columns in delimited text.

Swap Columns Tool

What Is the Swap Columns Tool?

The Swap Columns Tool rearranges two specific columns within any delimited text — CSV, TSV, pipe-separated, or custom. Specify which two columns to swap by number, and the tool instantly exchanges their positions across every row while leaving all other columns untouched.

How to Swap Columns in Text

  1. Paste your delimited data into the left text area — one row per line.
  2. Set the Delimiter to match your data format (comma, pipe, tab, etc.).
  3. Enter the column numbers to swap in Col A and Col B — both use 1-based indexing (first column is 1).
  4. The swapped output appears instantly on the right. Click Copy or Download .txt to save it.

Where Can You Use the Swap Columns Tool?

Name Formatting

Flip a "Last Name, First Name" export to "First Name, Last Name" order for email personalization or system imports that expect a different column sequence.

Database Schema Migration

Reorder exported SQL data columns to match the exact import schema of a target database or spreadsheet without touching a script or IDE.

API Response Normalisation

Reorder columns in a CSV extracted from an API response to match the column order required by your data pipeline or ETL tool.

Spreadsheet Import Prep

Rearrange columns in a bulk import file to align with a template before uploading to Shopify, WooCommerce, or any CMS that requires a fixed column order.

How the Column Swap Works

  • Exact delimiter split: Each row is split on the literal delimiter string. If Col A or Col B does not exist on a short row, that row is returned unchanged.
  • 1-based indexing: Column 1 is the first column — there is no column 0.
  • Swapping same column: If Col A equals Col B the output is identical to the input — no error, just a no-op.
  • Download: The result can be saved directly as a .txt file for use in other tools or systems.

Best Practices and Limitations

All processing runs locally in your browser — no data is sent to any server, making it safe for confidential or proprietary datasets.

This tool does not parse RFC 4180 CSV quoting. If your data has the delimiter character inside quoted fields (e.g., "Doe, Jr.",John), those fields will be split incorrectly. For complex quoted CSV files, use a spreadsheet application. If swapped values have unwanted spaces, pass the result through the Trim Whitespace Tool first.

Share This Swap Columns Tool

Know someone who needs to rearrange CSV columns quickly? Share this tool!

Frequently Asked Questions

How do I swap columns in my text?+

Simply specify the delimiter, enter the column numbers you want to swap in "Col A" and "Col B", and the tool will instantly rearrange them.

Does this work with CSV and TSV files?+

Yes! It works perfectly with commas, tabs, or any custom separator you specify.

Is my data secure?+

Absolutely. The tool operates completely offline within your browser, so your sensitive data is never uploaded.

Can I swap more than two columns?+

This tool is designed for swapping exactly two columns at a time. For complex reordering, you may need to use it multiple times.

What happens if a column number is out of range?+

The tool will simply leave that line unchanged or safely handle the missing column without breaking.