piapia123
en

CREATE TABLE to Code

Convert

Everything runs locally in your browser — nothing is uploaded

Input
Drop a file here to load its contents
Output

Turn one CREATE TABLE statement into four different things: JSON sample data for your API docs, an HTML form with the right control for each column, a Yii2 model (class, rules and attributeLabels), or a Postman collection with CRUD requests for that table, ready to import. Column types are inferred: int and decimal become numbers, tinyint(1) becomes a boolean, date and datetime get their own inputs, an enum becomes a select, and text or json becomes a textarea. Form labels prefer the column COMMENT, so the notes you wrote when creating the table finally earn their keep. The parser is written for real input: what you copy out of mysqldump or a GUI client arrives with conditional comments, DROP TABLE statements, index and foreign key definitions — all of which are skipped rather than breaking the parse.

Features

  • Four outputs: JSON sample data, an HTML form, a Yii2 ActiveRecord model and a Postman collection
  • Column types inferred: integers and decimals as numbers, tinyint(1) as boolean, date / datetime / time, json, text, enum
  • Form controls chosen by type: text, number, date, datetime, time, textarea, select for enums and a checkbox for booleans
  • Form labels prefer the column COMMENT and only fall back to the column name
  • Auto-increment primary keys are left out of the form — an ID box only suggests you have to fill one in
  • Nullable columns get no required attribute, and string columns carry their maxlength
  • The Yii model rules() covers every column, since Yii rejects attributes it has not been told about
  • Single quotes and backslashes are escaped correctly in the generated PHP
  • The Postman collection has List, Create, Get one, Update and Delete requests plus a baseUrl variable
  • Built for real input: conditional comments, DROP TABLE, index and foreign key definitions and line comments are all skipped
  • A double dash inside a COMMENT is not mistaken for a SQL line comment
  • Everything runs locally in the browser; your schema is never uploaded

How to use

  1. Paste the CREATE TABLE statement
  2. Pick what to generate
  3. Copy the result — the JSON and the Postman collection are ready to use; the form and the model need your own paths and namespace

FAQ

Which dialects are supported?
MySQL is the main target (MariaDB included): backticks, AUTO_INCREMENT, COMMENT, enum and tinyint(1) are all handled with MySQL semantics. Most PostgreSQL table definitions also yield their columns and types, though serial and ::text are treated as ordinary types. SQL Server names such as [dbo].[orders] are not recognised — you get a clear "no CREATE TABLE found" instead of a guess at the table name.
Can it handle more than one table at a time?
No. When the script contains several CREATE TABLE statements, only the first is used and the rest are ignored. All four outputs describe a single table — the form fields, the model class name, the collection paths — so generating them for four tables at once would produce a mixture nobody can use directly.
Why is the auto-increment primary key missing from the form?
Because whoever fills in a form should not be supplying that value. An ID input only makes people think they have to invent one, when the database or the backend owns it. The Yii model deliberately keeps id in rules(), matching Yii own gii generator, because it does need validating when an existing row is updated.
Why are the JSON values string, 0, 2026-01-01 and so on?
Because this is a skeleton, not mock data. Those values are obviously placeholders and will not be mistaken for real records, while the shapes they carry — numbers as numbers, booleans as booleans, json as an object — are the actual information: whether the example response in your API docs has the right structure. For realistic fake records, use the mock data tool instead.
How do I use the Postman collection?
Save the output as a .json file and import it in Postman via File → Import. The paths are built from the table name (a table called product becomes /product) and the baseUrl variable defaults to http://localhost:3000 — change that one variable after importing and the whole collection points at your environment. The POST and PUT bodies are the JSON skeleton for the table, so sending one immediately shows whether your backend accepts those fields.
Is my schema uploaded?
No. Parsing and generation happen entirely in browser memory; the page makes no requests and works offline. Table definitions carry naming conventions and business meaning, and none of it leaves your device.

Related tools