Skip to content

Write SQL directly in TypeScript.

A SQL-first data-access library. No query builder required.

SQLBraid lets you write SQL inside TypeScript tagged templates. Values are passed as bound parameters, and MyBatis-style dynamic conditions live in SQL comments. Each query declares its result type or validation schema.

Change the parameters and run the fixed query against an in-memory SQLite database in your browser.

Parameters

Clear a value to remove its condition. Values are bound as parameters, not inserted into SQL.

SQL · read-only

sql.rows`
  SELECT account_id, account_name, balance
  FROM finance_accounts
  /*@braid where*/
    /*@braid if ${currency !== ""} */
      AND currency = ${currency}
    /*@braid end*/
    /*@braid if ${minBalance !== null} */
      AND balance >= ${minBalance}
    /*@braid end*/
    /*@braid if ${search.trim().length > 0} */
      AND account_name LIKE ${`%${search.trim()}%`}
    /*@braid end*/
  /*@braid end*/
  ORDER BY balance DESC, account_id ASC;
`

Change the parameters and run the query.

Executed SQL and bound values

Rendered SQL

Run a query to see the statement sent to SQLite.

Bound parameters

[]

Query results

Open the full interactive preview to edit SQL and inspect the database schema.