SQL to CSV Converter

Transform SQL database dumps into CSV (Comma-Separated Values) format with customizable delimiters, quotes, and line endings

About SQL to CSV Converter

Convert SQL database dumps (CREATE TABLE and INSERT statements) to CSV (Comma-Separated Values) format. CSV is a universal data format supported by spreadsheet applications, databases, and data analysis tools. This converter provides full RFC 4180 compliance with customizable delimiters, quotes, and line endings.

Key Features

  • Multiple Delimiters: Comma, semicolon, tab, pipe, or custom delimiter
  • Custom Quote Character: Configure quote character for special values
  • Line Ending Options: LF (Unix/Mac) or CRLF (Windows)
  • RFC 4180 Compliant: Proper escaping and quoting of special characters
  • Header Support: Optional header row with column names
  • Smart Parsing: Extracts column names and data from SQL dumps
  • File Download: Save as .csv file

How to Use

  1. Input SQL Data: Paste your SQL CREATE TABLE and INSERT statements or upload a .sql file
  2. Choose Delimiter: Select comma, semicolon, tab, pipe, or custom delimiter
  3. Configure Options: Set quote character and line ending format
  4. Toggle Header: Enable or disable header row
  5. Copy or Download: Use the Copy or Download button to save your CSV

Delimiter Options

  • Comma (,): Standard CSV format, most widely supported
  • Semicolon (;): Common in European locales where comma is decimal separator
  • Tab (\t): TSV format, good for data with commas in values
  • Pipe (|): Alternative delimiter for special cases
  • Custom: Use any character as delimiter

Example Conversion

SQL Input:

CREATE TABLE products (
  id INT,
  name VARCHAR(100),
  price DECIMAL(10,2),
  category VARCHAR(50)
);

INSERT INTO products VALUES (1, 'Laptop', 999.99, 'Electronics');
INSERT INTO products VALUES (2, 'Mouse', 24.99, 'Accessories');

CSV Output (comma delimiter, with header):

id,name,price,category
1,Laptop,999.99,Electronics
2,Mouse,24.99,Accessories

CSV Output (semicolon delimiter, with header):

id;name;price;category
1;Laptop;999.99;Electronics
2;Mouse;24.99;Accessories

Common Use Cases

  • Excel Import: Import SQL data into Microsoft Excel or Google Sheets
  • Data Analysis: Use with Python pandas, R, or statistical tools
  • Database Migration: Transfer data between different database systems
  • Reporting: Generate reports from database queries
  • Data Backup: Create portable backups of database tables
  • ETL Pipelines: Extract data for transformation and loading

RFC 4180 Compliance

This converter follows RFC 4180 standard for CSV format:

  • Quoting: Values with delimiters, quotes, or newlines are quoted
  • Escaping: Quote characters inside values are doubled
  • Line Endings: Consistent line endings throughout file
  • Header Row: Optional first row with field names

Special Character Handling

Values Requiring Quotes:

  • Contains delimiter character
  • Contains quote character
  • Contains newline or carriage return

Quote Escaping:

  • Quote characters are doubled: " becomes ""
  • Example: "John "The Boss" Smith" becomes "John ""The Boss"" Smith"

Line Ending Options

LF (\n) - Unix/Mac:

  • Single line feed character
  • Standard on Unix, Linux, and macOS
  • Smaller file size

CRLF (\r\n) - Windows:

  • Carriage return + line feed
  • Standard on Windows systems
  • Better compatibility with Windows applications

Supported Applications

  • Microsoft Excel: Import CSV with Data > From Text/CSV
  • Google Sheets: File > Import > Upload CSV
  • LibreOffice Calc: Open CSV with delimiter detection
  • Python pandas: pd.read_csv() function
  • R: read.csv() or read.table() functions
  • MySQL: LOAD DATA INFILE command
  • PostgreSQL: COPY command

Best Practices

  • Include Headers: Enable header row for better data identification
  • Choose Appropriate Delimiter: Use semicolon if data contains commas
  • Match Line Endings: Use CRLF for Windows, LF for Unix/Mac
  • Test Import: Verify CSV imports correctly in target application
  • Handle Special Characters: Ensure proper quoting for complex data

Supported SQL Syntax

  • CREATE TABLE: Extracts column names for CSV headers
  • INSERT INTO: Parses data values from INSERT statements
  • Data Types: Handles all SQL data types (VARCHAR, INT, DECIMAL, etc.)
  • Quoted Strings: Handles single and double quotes with proper escaping

Frequently Asked Questions

  • Q: Why do some values appear in quotes? A: Any value containing the delimiter, quote character, or newlines is quoted to comply with CSV standards and import correctly in tools.
  • Q: Can I use a multi-character custom delimiter? A: Yes, but many CSV consumers expect a single character. Make sure your target application supports your chosen delimiter.
  • Q: How are NULL values represented? A: NULL and empty SQL values are exported as empty fields between delimiters so they can be interpreted as missing data.
  • Q: Which line ending should I choose? A: Use LF for Unix/macOS and most modern tools; use CRLF if your workflow or target application is Windows-centric.
  • Q: Why does my import shift columns? A: This usually indicates a delimiter mismatch or unescaped quotes. Verify the delimiter and that the target importer is set to the same delimiter and quote character.

Privacy & Security

All conversions happen locally in your browser. Your SQL data is never uploaded to any server, ensuring complete privacy and security.