๐Ÿ”„ SQL to Kysely

Convert SQL queries to Kysely TypeScript query builder code with type safety and compile-time checks

Zero Dependencies ยท Works Offline

๐Ÿ“ SQL Input

What is SQL to Kysely Converter?

SQL to Kysely is a free online developer tool that automatically converts SQL query statements into Kysely TypeScript query builder code. Kysely is a next-generation type-safe SQL query builder. This tool helps developers quickly migrate existing SQL to Kysely, enjoying TypeScript's type checking and intelligent hints. It supports SELECT, INSERT, UPDATE, DELETE and other common statements, automatically handling JOIN, WHERE, GROUP BY, ORDER BY clauses. All conversion happens locally in the browser โ€” your SQL data is never uploaded.

Core Features

How to Use

1. Paste or type your SQL query in the input area.

2. Select the database type (PostgreSQL/MySQL/SQLite) and code style options.

3. The tool converts in real-time, or click "Convert" to trigger manually.

4. View the generated Kysely TypeScript code in the result area. Copy or download as .ts file.

5. Use Ctrl+Enter to convert, Ctrl+Shift+C to copy results.

Use Cases

Case 1: Project Migration

Migrate existing raw SQL queries to Kysely for gradual type safety protection, reducing runtime SQL errors.

Case 2: Learning Kysely

Developers new to Kysely can input familiar SQL statements to learn the corresponding Kysely API usage.

Case 3: Code Review

Convert complex SQL queries to Kysely code for easier code review and version control in TypeScript projects.

Case 4: API Development

Backend developers quickly convert business SQL to Kysely queries for integration with Express/Koa/Fastify APIs.

Extended Knowledge

Kysely is a pure TypeScript SQL query builder developed by Koskimas. Its core advantage is compile-time type checking. It infers database table structures through generics, auto-completing column names and checking types as you write queries. Unlike Prisma, Kysely doesn't generate schema files โ€” it uses existing database structures directly. Compared to Knex, Kysely provides more complete TypeScript type inference. Best practices: define a Database interface describing table structures, use migrations for schema changes, and pair with kysely-codegen for automatic type generation.

โ“ FAQ

What is Kysely?

Kysely is a pure TypeScript SQL query builder that provides full type safety, supporting PostgreSQL, MySQL, SQLite and other databases with compile-time SQL error checking.

Which SQL statements are supported?

Supports SELECT (with JOIN/WHERE/GROUP BY/ORDER BY/LIMIT), INSERT, UPDATE, and DELETE statement conversions.

Can I use the converted code directly?

The converted code uses standard Kysely API calls and requires a Kysely instance with database type definitions. We recommend reviewing the output before integrating.

Is my data safe?

Absolutely. All SQL parsing and code generation happens locally in your browser. No data is ever uploaded to any server.

How does Kysely differ from Knex?

Kysely is pure TypeScript with full type inference and compile-time checking; Knex is JavaScript-based with weaker type support. Kysely is better suited for TypeScript projects.

Does it support subqueries?

Basic subquery conversion is supported, including WHERE clause subqueries and FROM derived tables. Complex nested subqueries may need manual adjustment.

How are table aliases handled?

The tool automatically detects SQL table aliases (AS keyword) and uses the corresponding alias methods in Kysely code.

SQL to Kysely | No Signup, Client-Side ยท No Server Uploads

Feedback: dexshuang@google.com