← CSV Repair & Deduper (offline browser tool)

Why a CSV looks fine in one program but broken in another (line-ending issues)

Why a CSV that opens fine on Windows sometimes shows every row squashed onto one line on Mac/Linux (or vice versa), and how to fix it.

Before you work through this by hand: you can check your own CSV free and see which of these problems your file actually has — duplicate rows, near-duplicates, broken quoting, encoding damage. It runs in your browser tab, nothing is uploaded, and there's no signup or email.

The three line-ending styles

Windows ends each line with two characters (carriage return + line feed, \r\n), while Mac and Linux use just one (line feed, \n). Very old Mac software used just a carriage return (\r). A CSV file is plain text, so it inherits whichever style the program that created it used — and a program expecting a different style can misread the file entirely.

What it looks like when this goes wrong

The most common symptom: opening a file in a text editor or tool that doesn't handle Windows-style line endings, and seeing every row's data run together as one enormous line, or seeing a stray character (often shown as ^M) at the end of each line.

Fixing it on the command line

On Linux/macOS: tr -d '\r' < file.csv > file_fixed.csv removes stray carriage returns, converting Windows-style line endings to Unix-style. On Windows, tools like Notepad++ have a "Convert line endings" option in the Edit menu, or `unix2dos`/`dos2unix` utilities handle it in either direction if you have them installed.

Fixing it in Python

import pandas as pd; df = pd.read_csv('file.csv'); df.to_csv('file_fixed.csv', index=False, lineterminator='\n') — reading with pandas and re-saving normalizes line endings to a single consistent style regardless of what the source file used.

Why this matters alongside other fixes

Line-ending issues often show up bundled with the delimiter and encoding problems covered in our broken-CSV guide — a file exported from an unfamiliar system is worth checking for all three at once rather than assuming only one is wrong.

$19 one-time payment. No subscription. If you'd rather skip the manual steps above, CSV Repair & Deduper (offline browser tool) automates the duplicate-finding and review step for you, entirely on your own device.

See CSV Repair & Deduper (offline browser tool) — $19 one-time

See all free guides