SQL to OpenAPI / JSON Schema Converter
Paste SQL CREATE TABLE statements and get OpenAPI 3.0 component schemas and JSON Schema with smart type mapping. Perfect for API documentation and contract-first development.
0
Tables
0
Schemas
0
Columns
0
Enums
Tip: Include
CHECK constraints with enum-like values (e.g., CHECK (status IN ('active', 'inactive'))) to auto-detect OpenAPI enums. Column COMMENT strings become schema descriptions.
# Select OpenAPI or JSON Schema, then paste SQL to generate
Need to compare two schemas?
SchemaLens diffs SQL schemas in your browser and generates migration scripts. Free for up to 15 tables.
Open SchemaLens Diff →How It Works
1. Paste SQL
Paste any CREATE TABLE dump. Supports PostgreSQL, MySQL, SQLite, SQL Server, and Oracle syntax.
2. Smart Type Mapping
SQL types are automatically mapped to OpenAPI formats: INTEGER → integer, TIMESTAMP → date-time, UUID → uuid, JSON → object.
3. Export & Use
Copy the generated schema into your openapi.yaml, Swagger UI, or JSON Schema validator. Download as .yaml or .json.
Supported Schema Features
- Type Mapping: All major SQL types mapped to OpenAPI/JSON Schema types and formats.
- Required Arrays:
NOT NULLcolumns are added to therequiredarray. - Nullable: Nullable columns get
nullable: true(OpenAPI) ortype: ["string", "null"](JSON Schema). - Enum Detection:
CHECK (col IN (...))constraints becomeenumarrays. - Descriptions: MySQL/PostgreSQL
COMMENTstrings become schemadescriptionfields. - Defaults:
DEFAULTvalues are preserved asdefaultin the schema. - Primary Keys: Marked with
x-primary-key: truevendor extension.