DiagramDB / CSV to MySQL

CSV to MySQL

Turn a CSV export into a MySQL table: a CREATE TABLE with sensible types and INSERT statements you can run as they are.

SQL · 3 rows
CREATE TABLE imported_rows (
  id INT NOT NULL,
  email VARCHAR(32) NOT NULL,
  signup_date DATE NOT NULL,
  plan VARCHAR(16) NOT NULL,
  monthly_fee DECIMAL(18,6) NOT NULL,
  is_active BOOLEAN NOT NULL
);

INSERT INTO imported_rows (id, email, signup_date, plan, monthly_fee, is_active) VALUES
(1, 'ada@example.com', '2026-01-14', 'pro', 29.00, TRUE),
(2, 'grace@example.com', '2026-02-02', 'free', 0, TRUE),
(3, 'O''Brien, Kate', '2026-02-19', 'team', 99.50, FALSE);

Detected columns

Types are inferred from every value in the column. Override any that are wrong: zip codes and phone numbers with leading zeros stay text on purpose.

ColumnTypeNullableLongest value
idno1
emailno17
signup_dateno10
planno4
monthly_feeno5
is_activeno5

Big file? Use MySQL’s bulk loader

Copy just the CREATE TABLE statement from the output above, run it, then load the whole file straight into the new table:

MySQL bulk import
LOAD DATA LOCAL INFILE 'data.csv'
INTO TABLE imported_rows
FIELDS TERMINATED BY ',' ENCLOSED BY '"'
LINES TERMINATED BY '\n'
IGNORE 1 ROWS;

LOCAL requires local_infile=1 on both the server and the client. Large INSERT scripts may hit max_allowed_packet (64 MB by default in 8.0); lower “Rows per INSERT” if they do.

Other databases

CSV to PostgreSQL · CSV to SQL Server · CSV to SQLite · CSV to Oracle · JSON to SQL

Questions

How do I convert a CSV file to MySQL INSERT statements?

Paste the CSV or open the file, check the detected column types, and copy or download the script. It contains a MySQL CREATE TABLE (optional) followed by multi-row INSERT statements in batches you choose.

How do I import a large CSV into MySQL?

For more than about 100,000 rows, use the bulk loader shown on this page. It is much faster than running INSERT statements. Generate the CREATE TABLE here, then bulk-load the file into it.

Which MySQL data types are used?

Whole numbers become integer types, decimals become exact numeric types (never floating point), true/false values become booleans, ISO dates and timestamps become date/time types, and everything else becomes a text type sized from the longest value. You can override any column.

Is my file uploaded?

No. The CSV is parsed and converted in your browser, and nothing is sent to a server.

Related tools