💙 Supporting healthcare non-profits: Metadataloop is free for 6–12 months. Contact Us to get started.
Free Online Tool

CSV to PostgreSQL CREATE TABLE

Paste a CSV sample, get a typed PostgreSQL DDL — no signup, no install.

Open the Schema Inferrer →

Overview

MetaDataLoop's schema inferrer reads a CSV sample and emits a complete PostgreSQL CREATE TABLE statement. Column types are inferred from the data: integers become INT or BIGINT depending on range, decimals become NUMERIC(p,s), text becomes VARCHAR(N) bucketed at 16/32/64/128/255/512/1024 (or TEXT beyond that), and ISO 8601 strings are detected as DATE or TIMESTAMP.

What you get

✓ INCLUDED
Auto-detects PostgreSQL-native types: INT, BIGINT, NUMERIC, BOOLEAN, DATE, TIMESTAMP, UUID, VARCHAR(N), TEXT
✓ INCLUDED
Nullable columns inferred from blank cells in your sample
✓ INCLUDED
VARCHAR length bucketed to common sizes — no overshoot
✓ INCLUDED
Outputs PostgreSQL-quoted identifiers when needed
✓ INCLUDED
Works on samples up to several MB — header row + 100s of rows is plenty

Type detection reference

Sample values and the dialect-native type they map to.

Sample valueInferred type
123, 4567INT
12345678901234BIGINT
12.45, 0.0009NUMERIC(10,4)
true, false, yes, noBOOLEAN
2024-03-15DATE
2024-03-15T09:30:00ZTIMESTAMP
a3bb189e-8bf9-3888-9912-…UUID
"Acme Corp"VARCHAR(64)
paragraph text > 1024 charsTEXT

Example

Input
id,email,signup_date,balance,is_active
1,alice@x.com,2024-03-15,1042.50,true
2,bob@y.com,2024-03-16,89.00,false
Output
CREATE TABLE customers (
    id          INT          NOT NULL,
    email       VARCHAR(64)  NOT NULL,
    signup_date DATE         NOT NULL,
    balance     NUMERIC(10,2),
    is_active   BOOLEAN      NOT NULL
);

Frequently asked questions

Does it support quoted CSV with commas inside fields?
Yes — standard RFC 4180 CSV is parsed correctly. Fields wrapped in double quotes can contain commas and escaped quotes.
How are decimals scaled?
We pick NUMERIC(precision, scale) by scanning the maximum digits before and after the decimal point in your sample. If your real data has more digits, supply a larger sample or edit the output.
Will it create a primary key?
No — primary key inference is heuristic and risky. Add PRIMARY KEY to the relevant column manually. Columns named id, *_id, or uuid are good candidates.

Try it now

No signup, no install — runs entirely in your browser.

Open the Schema Inferrer →

⚠ Confirm Delete