Santekno/toolsCategoriesTutorials

SQL → Go Struct

Convert a CREATE TABLE statement into an idiomatic Go struct with json/db/validate tags.

Processed in your browserUpdated · Jan 2026
Input
0 chars
Output
0 chars

How to use SQL → Go Struct

Paste your input on the left, choose the options you want, and the output appears instantly on the right. Everything runs in your browser — none of your data is sent to a server.

  • Paste or type your input in the INPUT panel
  • The output regenerates automatically as you type
  • Use Copy to put the result in your clipboard
  • Click Sample to load a working example

What is SQL → Go Struct?

SQL → Go Struct parses a `CREATE TABLE` statement and emits a Go struct ready to paste into your repo. Type mappings follow common Go conventions: INT/BIGINT/SERIAL → int64; VARCHAR(n)/TEXT → string; BOOLEAN → bool; TIMESTAMP/TIMESTAMPTZ → time.Time (with auto-import); UUID → uuid.UUID (or string per toggle); DECIMAL → string for precision (or float64 per toggle); JSON/JSONB → json.RawMessage. NOT NULL columns map to value types; nullable columns map to pointer types so a missing value is unambiguously expressible. Pairs with our existing JSON → Go Struct, Go Struct Tag Builder, and SQL → JSON Schema tools. This tool is part of santekno's developer toolbox — a curated collection of utilities built for engineers who care about speed, privacy, and simplicity.

Common use cases

  • Debugging API payloads and integration issues
  • Inspecting tokens, hashes, or encoded strings during development
  • Generating fixtures and sample data for tests
  • Sharing readable output with teammates in code reviews

FAQ

A NOT NULL column without DEFAULT must always be set by the caller — value type makes that explicit. NOT NULL with DEFAULT means the caller may omit it (DB will fill it in) — a pointer lets you express "I have no value, use the default".