Starting Postgres 18…

A type inference engine for Postgres, SQLite, and MySQL. Go to repo 👉

API

GET /play?q=<sql>

The playground's own link, asked for JSON, answers with the query's types, so a link you share works for an agent too.

curl -H 'accept: application/json' 'https://reylo.dev/play?q=select+name+from+users+where+id+%3D+%3Aid'

GET /play/api/analyze?q=<sql>

A query's params, return type, row type, cardinality and errors, analyzed against the playground's sample schema of users, posts and events and never run.

curl 'https://reylo.dev/play/api/analyze?q=select+name+from+users+where+id+%3D+%3Aid'
{
  "params": "{ id: number }",
  "returns": "{ name: string } | null",
  "element": "{ name: string }",
  "cardinality": "maybeOne",
  "diagnostics": []
}

GET /play/api/schema

The tables with their columns and types, and the functions and type names the editor completes.

curl 'https://reylo.dev/play/api/schema'

About

Reylo

Reylo is a general-purpose SQL type inference engine. Give it a query and a database, and it infers the query's parameters, its columns and their nullability, nested JSON shapes and cardinality, from the database's own analysis, with nothing declared by hand.

It is language-agnostic: TypeScript is one rendering of what it infers, JSON Schema another, and its API answers any language.

This playground

Edit the query, and the Params and Returns Reylo infers update as you type, with each error underlined where it is.

Postgres 18 runs in this tab, compiled to WebAssembly (PGlite), holding a sample schema of users, posts and events, or your own: View schema shows it, and Edit replaces it. Reylo's engine analyzes each query against it, also in this tab: nothing is run, and nothing is sent anywhere.

Next

Use it from TypeScript with the setup guide, or from any language, script or agent through the API. The docs cover the rest.

Query
select u.id, u.name,
  -- every post, as an array
  array(
    select p from (
      select id, title from posts where user_id = u.id order by id
    ) p
  ) as posts,
  -- the latest post, or null
  (
    select p from (
      select id, title from posts
      where user_id = u.id
      order by published_at desc nulls last
      limit 1
    ) p
  ) as latest_post
from users u
where u.id = :id::int