Code Generator•Free Online Tool

Convert PostgreSQL to Python Dataclasses

This free online PostgreSQL to Python Dataclasses generator turns your CREATE TABLE DDL statements into ready-to-use Python Dataclasses instantly — with no server upload, no account, and no rate limits. Simply paste your PostgreSQL schema on the left and the generated Python Dataclasses code appears on the right in real time. All processing runs entirely in your browser using client-side JavaScript, keeping your database schema 100% private.

SchemaForge

Code & Data Generator

100% Private
SQL Input

PostgreSQL → Python Dataclasses Type Reference

Complete type mapping from PostgreSQL SQL column types to Python Dataclasses — including nullability, constraints, and gotchas.

PostgreSQL TypePython Dataclasses TypeNotes
SERIAL / SMALLSERIALintfield(default=None) for auto-generated PK
BIGSERIALintPython int is arbitrary precision
INTEGER / INT / INT4int—
BIGINT / INT8int—
SMALLINT / INT2int—
NUMERIC / DECIMAL(p,s)DecimalImport from decimal module for exact arithmetic
REAL / FLOAT4float—
DOUBLE PRECISION / FLOAT8float—
VARCHAR(n) / TEXTstr—
CHAR(n)str—
BOOLEAN / BOOLbool—
TIMESTAMPdatetimefrom datetime import datetime
TIMESTAMP WITH TIME ZONEdatetimeUse timezone-aware: datetime.timezone.utc
DATEdatefrom datetime import date
TIMEtimefrom datetime import time
UUIDUUIDfrom uuid import UUID
JSONB / JSONdict[str, Any]from typing import Any; or define TypedDict
BYTEAbytes—
NOT NULL columnfield: TypeNo default; required at construction
NULL / nullable columnfield: Optional[Type] = Nonefrom typing import Optional

Frequently Asked Questions

Everything you need to know about converting PostgreSQL to Python Dataclasses.

How do I convert PostgreSQL to Python Dataclasses?

Paste your PostgreSQL CREATE TABLE statements into the SQL editor on the left. The Python Dataclasses output appears instantly on the right panel in real-time as you type.

Is my SQL schema data private?

Yes — completely. The entire conversion runs inside your browser using JavaScript. Your SQL is never sent to any server, logged, or stored anywhere. This makes it safe to use with production or confidential database schemas.

Which SQL dialects are supported?

PostgreSQL, MySQL, SQLite, SQL Server, Oracle, and MariaDB DDL syntax are all supported. The parser auto-detects the dialect from your CREATE TABLE syntax automatically.

Can I convert multiple tables at once?

Yes! Paste multiple CREATE TABLE statements separated by semicolons and all tables will be converted simultaneously, including cross-table foreign key relationships.

Does this tool support nullable columns and constraints?

Yes. NULL, NOT NULL, DEFAULT values, PRIMARY KEY, UNIQUE, and FOREIGN KEY constraints are all parsed and reflected in the Python Dataclasses output. Nullable columns are correctly typed as optional properties or nullable types.

Is SchemaForge free to use?

Yes, SchemaForge is completely free with no usage limits, no account required, and no rate limits. The tool runs entirely in your browser and will always be free.

Related Code Generators