Data Tool Runs in your browser. Nothing is uploaded.

CSV Doctor: Repair Broken CSV Files

Intelligently detect bad quotes, misaligned delimiters, encoding flaws, and ragged rows with full change verification.

Original CSV

0 lines | 0 chars | 0 KB

Fixed CSV

0 rows × 0 cols

How to Repair Broken CSV Files Online

Comma-Separated Values (CSV) are the world's most ubiquitous interchange format for data science, spreadsheets, ERP systems, and SQL databases. Despite their conceptual simplicity, real-world CSV files break constantly. Missing quotes, mismatched delimiters, ragged row lengths, and encoding conflicts turn simple file imports into multi-hour troubleshooting nightmares.

CSV Doctor is an intelligent, free, client-side repair engine created by MafLabs. Built with deterministic algorithmic heuristics and zero third-party telemetry, CSV Doctor diagnoses syntax anomalies, corrects structural deformities, and provides an audited change log without transmitting a single byte of your confidential data outside your web browser.

How to Use CSV Doctor in 4 Easy Steps

  1. Import or Paste Your Raw File: Drag and drop your broken CSV, TSV, or TXT file directly into the left editor pane, or click Open File. You can also paste directly from your clipboard.
  2. Review Automatic Diagnostics: CSV Doctor immediately executes deterministic token analysis to detect character encoding (UTF-8, UTF-16, Windows-1252), scoring delimiter distributions and flagging anomalous rows.
  3. Inspect the Changes & Table Preview: Switch to the Table Preview to visually inspect your repaired data. Discrepancies and merged columns are highlighted in warm amber with instant tooltip explanations.
  4. Export Cleaned Data: Download your validated CSV with Excel-ready UTF-8 BOM, export clean TSV, or generate a JSON array of objects with one click.

Before and After Repair Example

Consider a typical corrupted CRM export containing unescaped quotes, mismatched delimiter commas inside addresses, and ragged row lengths:

Broken Input CSV
id,name,address,notes,balance
101,John "Jack" Doe,124 Elm St, Springfield,VIP Client,$1,200.00
102,Acme Corp,PO Box 44, "Urgent" follow-up
103,Sarah O'Connor,456 Oak Ave, Seattle,WA,Active,$850.00
104,Jane Smith,789 Pine Rd, Portland,NULL,-
Repaired Clean CSV (RFC 4180)
id,name,address,notes,balance
101,"John ""Jack"" Doe","124 Elm St, Springfield",VIP Client,1200.00
102,Acme Corp,PO Box 44,"Urgent follow-up",
103,Sarah O'Connor,"456 Oak Ave, Seattle, WA",Active,850.00
104,Jane Smith,789 Pine Rd,Portland,,

Why CSV Files Break: Technical Explanation

While Internet standard RFC 4180 outlines formal specifications for CSV, software applications frequently generate ad-hoc formats. Here is why data pipelines encounter recurring failures:

  • Delimiter Collision: In European territories where the comma represents a decimal separator (e.g. 12,50 €), software typically uses semicolons (;) as delimiters. Opening a European CSV in a US-configured spreadsheet reads the entire line as a single monolithic cell.
  • Unescaped Quotation Marks: RFC 4180 requires literal quotation marks within quoted fields to be doubled (e.g. "12"" monitor"). Unsanitized database exports frequently emit single double-quotes, causing the parser to treat everything until the next line's quote as a single gargantuan text field.
  • Ragged Rows & Split Addresses: When text fields contain commas (like street addresses or city-state combinations) without wrapping quotation marks, downstream parsers split the field across multiple columns. This misaligns data columns across the entire rest of the row.
  • Character Encoding Mismatches: Files encoded in Windows-1252 or ISO-8859-1 that contain accents (é, ñ, ü) display as garbled glyphs (e.g. é) when ingested by modern UTF-8 parsers without byte order markers.

Common Problems Handled by CSV Doctor

Unterminated Swallow Quotes

Detects when an unclosed quote consumes multiple following rows, restoring intended row boundaries automatically.

Duplicate & Blank Headers

Automatically deduplicates repeated column titles (e.g., id, id_2) and generates fallback labels for empty header slots.

Leading Zero Preservation

Guarantees that zip codes (02138) and serial numbers are formatted so spreadsheet software won't silently erase leading zeros.

Excel Formula Injection Mitigation

Prefixes suspicious formula trigger characters (=, +, -, @) with single quotes to shield spreadsheet users from remote execution vulnerabilities.

Frequently Asked Questions

Why does my CSV break when opened in Microsoft Excel?

Excel enforces strict regional defaults. If your operating system locale uses commas for decimals, Excel expects semicolons as list separators. Furthermore, UTF-8 files opened without a Byte Order Mark (BOM) cause Excel to fall back onto ANSI decoding, scrambling special characters. CSV Doctor attaches a UTF-8 BOM and allows you to pick the exact export delimiter required for your locale.

What is a delimiter and how does CSV Doctor identify it?

A delimiter is the boundary character separating data fields. CSV Doctor runs an entropy-based scoring pass across candidate delimiters (comma, semicolon, tab, and pipe), evaluating field count uniformity across sample rows. The delimiter that produces the most consistent rectangular matrix with the lowest standard deviation is selected automatically.

Why do I see strange characters like "é" or "’" in my records?

This artifact, known as mojibake, occurs when multi-byte UTF-8 sequences are misinterpreted as single-byte legacy encodings such as Windows-1252 or Latin-1. CSV Doctor analyzes binary byte signatures and lets you switch between decoders in real time to restore proper typography without data degradation.

Is my file uploaded to MafLabs or any external server?

No. CSV Doctor is 100% browser-native and functions offline. All parsing, fixing algorithms, table virtualization, and file generations execute strictly inside your browser's sandboxed JavaScript runtime and Web Workers. Zero telemetry, cookies, or remote payloads touch your content.

Can CSV Doctor handle large files up to 100 MB?

Yes. Heavy calculations run off the main browser thread via Web Workers. This ensures your browser tab stays fluid and responsive while processing tens of thousands of rows.

How does CSV Doctor fix ragged rows with mismatched column counts?

Rows with too many fields are commonly caused by unquoted commas in description or address columns. CSV Doctor inspects column datatypes and merges extraneous fields into the column exhibiting free-text characteristics, clearly tagging the decision as a "Guessed" fix in the audited change log.