Free dbt Schema.yml Generator

Turn any CREATE TABLE into a complete dbt scaffold in one click. Paste a CREATE TABLE statement - from Snowflake, PostgreSQL, Redshift, BigQuery, or ANSI SQL - and get three artifacts: a schema.yml with inferred unique and not_null tests, a staging SQL model using the canonical with source, renamed pattern, and a sources.yml entry with freshness checks. No warehouse connection, no dbt codegen, no account required.

Why use a dbt schema generator?

Writing schema.yml files by hand is tedious and error-prone. dbt codegen does this against a live warehouse connection, but sometimes you don't have one yet - you're reviewing a CREATE TABLE in a pull request, designing a new staging layer from a data-contract doc, or bootstrapping a dbt project offline. This tool solves the offline case. Feed it any CREATE TABLE and get a schema.yml starting point in seconds.

What tests get inferred?

Generated artifacts explained

schema.yml

A dbt YAML doc with version: 2, a single models: entry, column list with descriptions and tests. Column descriptions are inferred from naming conventions (_id columns become foreign-key descriptions, _at columns become event timestamps, status/amount/email get intuitive descriptions). Always review and rewrite with business context - good column documentation is the single highest-ROI item in a dbt project.

Staging SQL model

A .sql file using the dbt style-guide pattern: with source as (...), renamed as (...) select * from renamed. The source CTE pulls from {{ source('...', '...') }}; the renamed CTE is where you add column casts, renames, or surrogate keys like {{ dbt_utils.generate_surrogate_key(['order_id']) }}.

sources.yml

A sources.yml entry with loaded_at_field and freshness thresholds (warn after 12 hours, error after 24 hours - tune to your SLA). Lets you run dbt source freshness to detect stale ingestion.

Where to place the generated files

  1. Staging SQL -> models/staging/<source>/stg_<table>.sql
  2. schema.yml -> models/staging/<source>/schema.yml (one file per source folder is the dbt style-guide convention)
  3. sources.yml -> models/staging/<source>/sources.yml
  4. Run dbt build --select stg_<table>+ to compile, test, and materialize the model.

Related tools and reading

Need a CREATE TABLE first? Use the JSON to SQL DDL Generator or the CSV to SQL Converter, then pipe the output here. Price your dbt Cloud usage with the dbt Cloud Cost Calculator. For dbt command syntax see the dbt Commands Reference.

← Back to Home