SchemaForgeSCHEMA CONVERTER

Five schema formats · any direction · no upload

One schema, five formats, converted in the browser

Write the shape of your data once. SchemaForge reads SQL DDL, TypeScript types, Zod objects, Pydantic v2 models and JSON Schema, turns any of them into one neutral model, and writes the other four from it — while you type. Optional and nullable fields, defaults, VARCHAR lengths, numeric bounds, CHECK enums and doc comments are carried across instead of being flattened away. No account, no upload, no server call: the parser and the generators are JavaScript in this tab.

Formats SQL · TS · Zod · Pydantic · JSON SchemaDirections 20 source/target pairsNetwork 0 requests from the tool

Schema converter

Converted output

    

    Nothing is uploaded. Conversion happens on every keystroke, and the diagnostics list shows what the neutral model could not hold.

    Features

    What the converter does

    Six things, all without a server.

    ANY→ANY

    Five formats, every direction

    Choose the source at the left and the target at the right. SQL DDL, TypeScript, Zod, Pydantic v2 and JSON Schema all parse and all generate, so any pair works — including SQL to Zod and Pydantic to TypeScript.

    MODEL

    A real model in the middle

    Every field becomes a name, a type, whether it may be null, whether it may be omitted, its default, length, numeric bounds, pattern, enum values and comment. Generation reads that model, not the original text.

    OPTIONAL

    Optional and nullable kept apart

    A column with DEFAULT is optional but not null; a nullable column is null but not omitted. Each target gets the right spelling: ? and | null, .optional() and .nullable(), Optional[...] and = None.

    CASE

    Key case on the way out

    Keep the names as written, or convert every field to snake_case, camelCase or PascalCase in all targets at once. Identifiers that would be invalid in the target language are made valid and the change is reported.

    CONSTRAINTS

    Lengths, ranges and enums survive

    VARCHAR(120) becomes .max(120) and max_length=120 and maxLength: 120. CHECK (status IN (...)) becomes a Zod enum, a TypeScript literal union, a Pydantic Literal and a JSON Schema enum.

    DIAGNOSTICS

    Errors with a line and a column

    A syntax error names the line and column it stopped at. Things the neutral model cannot hold — a foreign key, an unusual CHECK expression — are listed as warnings instead of disappearing.

    How it works

    Four steps, no setup

    The converter is one page and runs on every keystroke.

    01

    Pick the source format

    SQL, TypeScript, Zod, Pydantic or JSON Schema. Loading a sample shows the expected syntax for that format.

    02

    Paste your schema

    Paste the table, interface, z.object or model. Conversion runs as you type; nothing is submitted.

    03

    Choose the target and options

    Pick the output format, the key case, and whether defaults and nullable fields become optional.

    04

    Copy or download

    The result is syntax-highlighted text with a copy button and a download in the target's own extension: .ts, .py, .sql or .json.

    Coverage

    What each format reads and writes

    One model, five dialects. The notes say where a dialect stops.

    FormatReadsWritesNotes
    SQL DDLCREATE TABLE with column types, NOT NULL, NULL, DEFAULT, PRIMARY KEY, UNIQUE, CHECK (col IN (...)), REFERENCES, -- and /* */ commentsCREATE TABLE per model, VARCHAR(n), NUMERIC, BOOLEAN, TIMESTAMP, DATE, UUID and JSON columns, CHECK IN for enumsGeneric, PostgreSQL-flavoured syntax. Table names are the plural snake_case of the model name.
    TypeScriptexport interface and type X = { … }, ? optional, | null, string-literal unions, T[] and Array<T>, inline nested objects, // and /** */ commentsexport interface per model with JSDoc comments, primitives, arrays, literal unions and nested object typesTypes describe JSON payloads, so a timestamp is string and an integer is number.
    Zodz.object with .optional(), .nullable(), .default(), .min(), .max(), .int(), .regex(), .email(), .describe(), z.enum, z.array, z.literalz.object chains plus an exported z.infer type alias per modelZod v3 method names. Objects are .strict() when the strict option is on.
    Pydantic v2class X(BaseModel): with annotations, Optional[...], | None, Literal[...], list[...], dict[...], Field(...) with max_length, ge, le and patternBaseModel classes with Field(...) constraints, Literal unions and model_config = ConfigDict(extra="forbid") when strictPydantic v2 spelling (ConfigDict). v1’s class Config is not generated.
    JSON SchemaDraft 2020-12 objects: properties, required, type, enum, const, format, min/max, minLength/maxLength, pattern, items, $defs and local $refOne Draft 2020-12 document, every extra model in $defs, the first model as the entry pointadditionalProperties: false when the strict option is on; type arrays for nullable scalars.

    Anything a format cannot express is reported, not guessed: a foreign key, an unusual CHECK expression or a nested object written to a SQL table appears in the diagnostics list next to the output.

    Under the hood

    Parse, model, generate

    Each source is parsed into the same small model, and each target is written from that model.

    SQL / TS / Zod / Pydantic / JSON Schema→parse→neutral model→generate→the other four
    Field name, type, required, nullable, defaultType string, int, number, bool, date-time, uuid, enum, array, objectConstraints maxLength, minLength, minimum, maximum, patternOutput comments as JSDoc, docstrings, SQL comments and description

    The parsers are small hand-written readers, one per format. The SQL reader walks the statements of a CREATE TABLE, takes the type before the first option keyword and then reads NOT NULL, DEFAULT, PRIMARY KEY, UNIQUE and CHECK (col IN (...)) in any order. The TypeScript reader takes the brace-matched body of an interface or type alias and splits fields at top-level semicolons. The Zod and Pydantic readers follow method chains and indentation respectively, and the JSON Schema reader is a JSON parse followed by a walk over properties, $defs and $ref.

    All five land on the same model: a list of models, each with a list of fields. A field carries a name, a type node, and three independent flags — required, nullable and optional — plus a default, a comment and any constraints the source expressed. Keeping required, nullable and optional apart is what lets OPTIONAL survive a trip from SQL (NOT NULL, DEFAULT NULL) to TypeScript (name?: string | null) and back.

    Generation is the mirror image. Names are converted with the case option, defaults are turned into initialisers or left out, enums become the target's own construct, and comments become whatever documentation the target has — JSDoc for TypeScript and Zod, docstrings for Pydantic, -- lines for SQL and description for JSON Schema.

    Questions

    Frequently asked

    Is my schema sent to a server?

    No. Parsing and generation are JavaScript in this page: there is no fetch, no XHR and no beacon in the tool, which you can confirm in your browser's network panel. Only the advertising script in the page head is loaded from outside. Your last schema and options are kept in this browser's localStorage so a reload does not lose your work; clear site data to remove them.

    Why are optional and nullable different?

    They answer different questions. Nullable asks whether the value may be null; optional asks whether the field may be missing altogether. A SQL column with a DEFAULT is normally optional but not nullable, and an API payload may have a key that is always present but may be null. Keeping them apart produces the right output — name?: string | null, z.string().nullable().optional(), Optional[str] = None — and the two options let you collapse them if your project treats them as one.

    What happens to things the model cannot hold?

    They are reported. A FOREIGN KEY, an unknown CHECK expression or an unsupported type is listed in the diagnostics list with the field name, so nothing is silently dropped. Foreign keys are the clearest case: a table relation is not a value shape, so SchemaForge does not invent a reference type for it.

    How are enums handled?

    SQL has no portable enum, so CHECK (col IN ('a','b')) is read as an enum and written back the same way. In between it becomes a Zod z.enum, a TypeScript string-literal union, a Pydantic Literal[...] and a JSON Schema enum. A VARCHAR with no CHECK stays a plain string.

    Does a conversion round-trip perfectly?

    For the constructs listed in the coverage table, yes — the same model is produced from generated code as from the original. Outside that set it does not: vendor-specific types, table options, indexes, constraints in prose and Pydantic validators are not part of the model, so they do not come back. Treat the output as a starting point and diff it against your original before committing.

    Which SQL dialect is used?

    A generic one that leans PostgreSQL: VARCHAR(n), NUMERIC(p,s), BOOLEAN, TIMESTAMP, DATE, UUID and JSON columns, quoted identifiers, several statements separated by semicolons. It will not read every vendor extension, and it writes no dialect-specific clause that another database would reject silently.

    Honest limits

    What this tool does not do

    Not a full SQL parser

    CREATE TABLE is read. ALTER TABLE, views, indexes, sequences, generated columns and dialect-specific types are not, and a file containing them should be reduced to the CREATE TABLE statements you care about.

    Relations are not modelled

    Foreign keys are reported as warnings rather than turned into references, because none of the other four formats describes a database relation. Composite keys are read but only the primary-key flags survive.

    Type mapping is a convention

    A timestamp becomes string in TypeScript, datetime in Pydantic and format: date-time in JSON Schema; an object nested in a row becomes a JSON column in SQL. Sensible defaults, but your project may want different ones.

    Generated code needs a review

    Table names are pluralised with English rules, field order follows the source, and the output is formatted for reading. Check names against your conventions, then run your own type checker or linter over the result.

    Standards the output follows

    • JSON Schema — Draft 2020-12, $defs and $ref
    • Pydantic — version 2 (ConfigDict, Field, Literal)
    • Zod — version 3 (z.object, z.enum, z.infer)
    • Privacy — no upload, no account, no analytics; your work stays in localStorage