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

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

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.