Type object
File match .kysely-codegenrc.json **/.kysely-codegenrc.json
Schema URL https://catalog.lintel.tools/schemas/kysely/kysely-codegen/latest.json

Validate with Lintel

npx @lintel/lintel check
Type: object

Configuration file for kysely-codegen, a TypeScript type generator for Kysely.

kysely-codegen introspects your database and generates TypeScript type definitions so that Kysely queries are fully typed. Configuration is read from .kysely-codegenrc.json in the project root. CLI arguments take precedence over config file values.

See the kysely-codegen README for full documentation.

Properties

camelCase boolean

Use the Kysely CamelCasePlugin for generated table column names. When enabled, column names like created_at become createdAt in the generated types.

Default: false
dateParser string

Specifies which parser to use for PostgreSQL date/time values.

  • timestamp — Dates are typed as Date (default)
  • string — Dates are typed as string
Default: "timestamp"
Values: "string" "timestamp"
defaultSchemas string[]

Sets the default schema(s) for the database connection. Tables in these schemas are generated without a schema prefix.

Defaults to ["public"] for PostgreSQL and [] for other dialects.

Examples: ["public"], ["public","auth"]
dialect string

Sets the SQL dialect. If not provided, it is inferred from the connection string URL.

  • postgres — PostgreSQL
  • mysql — MySQL / MariaDB
  • mssql — Microsoft SQL Server
  • sqlite — SQLite (via better-sqlite3)
  • bun-sqlite — SQLite via Bun's built-in SQLite
  • kysely-bun-sqlite — SQLite via kysely-bun-sqlite
  • worker-bun-sqlite — SQLite via Bun worker
  • libsqllibSQL (Turso)
Values: "bun-sqlite" "kysely-bun-sqlite" "libsql" "mssql" "mysql" "postgres" "sqlite" "worker-bun-sqlite"
domains boolean

Controls whether to generate types for PostgreSQL domains. Only relevant when using the postgres dialect.

Default: true
envFile string

Path to an environment file (e.g. .env) to load before reading the connection string. Useful when DATABASE_URL is defined in an env file.

Examples: ".env", ".env.local"
excludePattern string | null

A glob pattern to exclude tables from code generation. Tables matching this pattern are skipped.

Default: null
Examples: "_prisma_*", "migrations_*"
includePattern string | null

A glob pattern to include only matching tables in code generation. Tables not matching this pattern are skipped.

Default: null
Examples: "user*", "public.*"
logLevel string

Sets the terminal log level.

  • debug — All messages
  • info — Informational and above
  • warn — Warnings and errors (default)
  • error — Errors only
  • silent — No output
Default: "warn"
Values: "debug" "info" "warn" "error" "silent"
numericParser string

Specifies which parser to use for PostgreSQL numeric / decimal values.

  • string — Typed as string (default, preserves precision)
  • number — Typed as number (may lose precision for large values)
  • number-or-string — Typed as number | string
Default: "string"
Values: "number" "number-or-string" "string"
outFile string | null

Sets the output file path for the generated type definitions. When set to null, uses the default path inside node_modules.

Default: null
Examples: "./src/db.d.ts", "./types/database.ts"
overrides object

Specifies type overrides for specific table columns. Allows you to manually set the TypeScript type for columns where the inferred type is not ideal.

1 nested properties
columns Record<string, string>

A map of "table.column" (or "schema.table.column") to a TypeScript type expression string.

Examples: {"user.id":"Generated<string>","post.metadata":"Record<string, unknown>"}
partitions boolean

Includes PostgreSQL table partitions in the generated code. Only relevant when using the postgres dialect.

Default: false
print boolean

Prints the generated output to the terminal (stdout) instead of writing to a file. Useful for previewing output or piping to other tools.

Default: false
runtimeEnums boolean | string

Generates TypeScript enum declarations for PostgreSQL enum types instead of union types. Only relevant when using the postgres dialect.

  • false — Generate union types like "a" | "b" (default)
  • true — Generate runtime enums with default naming
  • "pascal-case" — Generate enums with PascalCase member names
  • "screaming-snake-case" — Generate enums with SCREAMING_SNAKE_CASE member names
Default: false
singularize boolean | object

Singularizes generated type aliases (e.g. Users becomes User).

  • false — No singularization (default)
  • true — Use built-in singularization rules
  • {...} — A record of regex pattern to replacement string for custom singularization rules
Default: false
skipAutogeneratedFileComment boolean

Skips adding the // This file was generated by kysely-codegen comment at the top of the generated file.

typeOnlyImports boolean

Uses TypeScript's import type syntax in the generated code (e.g. import type { ColumnType } from 'kysely' instead of import { ColumnType } from 'kysely').

Default: true
url string

The database connection string URL. If not provided, reads from the DATABASE_URL environment variable.

Examples for each dialect:

  • PostgreSQL: postgres://user:pass@localhost:5432/mydb
  • MySQL: mysql://user:pass@localhost:3306/mydb
  • SQLite: C:/path/to/db.sqlite or :memory:
  • libSQL: libsql://your-db.turso.io
  • MSSQL: Server=localhost;Database=mydb;User Id=sa;Password=pass;
verify boolean

Verifies that the generated types are up-to-date without writing any files. Exits with a non-zero code if the output file would change. Useful in CI pipelines.