About
Tool No. 27 of Pikkola
Two things in SQL get typed by hand more than anything else: the query someone pastes into a client, and the CREATE TABLE someone pastes into a migration. This studio is built around those two texts.
What it does
- Formats a query for PostgreSQL, MySQL or SQLite, with one clause per line and one column per line, and minifies it back to a single line.
- Reads CREATE TABLE statements and writes the TypeScript interface, Zod schema, Prisma model and Pydantic class that match them.
- Checks both texts against eighteen rules: a DELETE without WHERE, a LIKE that starts with a wildcard, a comparison with NULL, a table without a primary key, and the rest of the list on the front page.
How it is built
There is one lexer. It reads the text once into tokens and keeps the line number of each one. The formatter lays those tokens out, the DDL reader groups the tokens inside a CREATE TABLE into columns and keys, and the checker matches small patterns over the same tokens, which is why the line a finding names is the line in your editor.
The formatter is not a parser for SQL. It knows clauses, parentheses, subqueries, string and identifier quoting, comments, casts and operator precedence well enough to lay text out, but it does not build an abstract syntax tree. That trade means it never rejects your input: an unfinished statement comes back spaced correctly instead of with an error. It also means it cannot rename, reorder or rewrite anything, which is a feature when the query goes into production.
What it deliberately does not do
- It does not connect to a database. There is no connection string field, no schema import and no query execution, so nothing can be changed by mistake.
- It does not run EXPLAIN. A clean sheet from the checker means the common mistakes are absent, not that a query is fast; only the plan and the data can say that.
- It does not try to produce a complete ORM schema. Enums, check constraints, indexes, views and triggers are left alone, and a relation to a table you did not paste is reported rather than invented.
- It does not send, store or count anything you paste. See Privacy.
Why it is free
Pikkola builds small, single purpose tools and keeps them free, with no account and no advertising. They run in the browser, so serving them costs almost nothing and there is no reason to charge for this one.
Contact
Bugs, awkward SQL that formats badly, or a rule you think is wrong: hello@pikkola.com. A pasted statement that produces a strange result is the most useful report there is.