Tools

Home
JSON FormatterSQL FormatterJS ValidatorMinify CSS
Merge PDFCompress PDFImage to PDF
JPG to PNGPNG to WebPCrop Image

Trim CSV Columns

Remove leading and trailing whitespace from CSV field values with configurable trim modes

Your files never leave your browser
CSV Input0 chars, 0 lines
Drag & drop a CSV file here, or browse
Accepts .csv, .tsv, .txt files
Trimmed Output0 chars, 0 lines
Ready·

Strip invisible spaces, tabs, and trailing whitespace from CSV fields — pick a trim mode (both sides, leading, or trailing) and target all columns or just the ones that need cleaning. And everything runs in your browser. Nothing gets uploaded.

How It Works

Paste or Upload CSV
➞
Strip Whitespace per Field
➞
Copy or Download Clean CSV

The parser reads your CSV line by line, respecting quoted fields and escaped characters. For each field, it applies the trim mode you selected — stripping spaces, tabs, and other whitespace from the start, end, or both. Quoted values get re-quoted automatically so the output stays valid CSV. The delimiter (comma, tab, or semicolon) is auto-detected from your first row.

Examples

Cleaning Up a Contact Export

Your CRM exported names with trailing spaces that break mail merge fields.

INPUT
name , email , city Alice ,[email protected] , New York Bob , [email protected], London
OUTPUT
name,email,city Alice,[email protected],New York Bob,[email protected],London

Trimming Only the Price Column

Product descriptions have intentional leading spaces for formatting, but the price column picked up junk whitespace from a database dump. Target just that column.

INPUT
sku, description, price A01, Widget Pro, 9.99 A02, Gadget Max, 14.50 A03, Thingamajig, 7.25
OUTPUT
sku, description,price A01, Widget Pro,9.99 A02, Gadget Max,14.50 A03, Thingamajig,7.25

Fixing Tab-Separated Data with Trailing Spaces

You copied rows out of a spreadsheet and every cell ended up with trailing tabs and spaces. Quick cleanup before pasting into a SQL INSERT statement.

INPUT
id status score 101 active 88 102 pending 73 103 done 95
OUTPUT
id status score 101 active 88 102 pending 73 103 done 95

Who Uses This

💻 Developers

Clean CSV exports before feeding them into ETL pipelines or database imports where stray spaces cause key mismatches.

📊 Data Analysts

Fix messy survey data or CRM exports so pivot tables and GROUP BY queries don't split "London" and "London " into two categories.

💼 Project Managers

Tidy up exported task lists from Jira, Asana, or Trello before sharing them in reports or importing into another tracker.

🎓 Students

Clean dataset files before running stats homework — no more "column not found" errors from invisible trailing spaces in headers.

Common Mistakes

Trimming all columns when only one needs it

If a "description" column has intentional leading spaces for indentation, trimming everything wipes that formatting out. Switch to "Specific Columns" mode and check only the columns that actually have junk whitespace.

Forgetting the header row gets trimmed too

Headers are treated like any other row. If your header is " name " and you trim it to "name", downstream code expecting the original header string might break. Usually this is a good thing — but double-check if something depends on the exact header text.

Using "Leading Only" when you need both sides

Trailing spaces are the most common culprit in broken imports. If you pick "Leading Only" mode, those trailing spaces stick around. When in doubt, leave it on "Both" — that covers 95% of cases.

Technical Details

Frequently Asked Questions

What counts as whitespace when trimming CSV columns?

Spaces, tabs, non-breaking spaces, and other Unicode whitespace characters. The tool uses a standard regex pattern that catches all of them. Middle-of-field spaces (like "New York") are left alone — only the stuff at the edges gets removed.

Can I trim whitespace from a CSV file without uploading it?

Yes. This tool runs entirely in your browser. You can paste data directly or drag a file in — either way, nothing is sent to a server. Your file doesn't leave your computer.

How do I remove extra spaces from specific CSV columns only?

Change the "Target columns" dropdown to "Specific Columns." The tool reads your header row and shows checkboxes for each column. Uncheck the ones you want to leave alone. Only checked columns get trimmed.

Does trimming CSV whitespace break quoted fields?

No. The parser handles RFC 4180-style quoting correctly. It strips whitespace from the field value itself, then re-applies quotes if the result contains a delimiter, newline, or quote character. Your output stays valid CSV.

Why do my CSV columns have extra spaces in the first place?

Usually from copy-pasting out of spreadsheets, database exports that pad fixed-width columns, or manual data entry where someone hit the spacebar by accident. Some tools also add spaces after delimiters for readability. Whatever the cause, this tool fixes it in one click.

Share: