If you work with Laravel, you have probably faced this situation at least once.
You get an old database. Maybe it's a .sql file from a client, or a MySQL schema from a previous project. Now you have to bring it into a Laravel app, and Laravel wants migrations.
So you open the SQL file and start writing Schema::create() by hand. Table by table. Column by column. VARCHAR(255) becomes string(), BIGINT UNSIGNED becomes unsignedBigInteger(), and then you do the same for indexes and foreign keys.
It's boring work, and it's easy to make small mistakes. I got tired of it, so I built a tool for it.
Meet the SQL to Laravel Migration Converter
It's a free online tool on AabiTech. You paste your SQL CREATE TABLE statements, and it gives you Laravel migration code.
No signup, no install. You just open it in your browser and use it.
How to use it
- Paste your SQL schema, or import a
.sqlfile. - Pick your SQL dialect, or leave it on auto detect.
- Choose your Laravel version.
- Copy the migration, or download it as a ZIP.
That's it.
A quick example
Say you have this SQL:
CREATE TABLE users (
id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL UNIQUE,
created_at TIMESTAMP NULL,
updated_at TIMESTAMP NULL
);
You get a Laravel migration with the Schema::create structure, the right column methods, and the unique index. The exact output depends on the options you pick (more on that below).
What I like about it
It works in your browser. Your SQL is parsed and converted locally. It is not sent to my server. This matters because database schemas can be sensitive, and I wouldn't want to paste a client's schema into a random website either.
It supports several SQL dialects. MySQL / MariaDB, PostgreSQL, SQLite, and SQL Server. Or you can let it auto detect.
It supports multiple Laravel versions. You can target Laravel 9, 10, 11, 12, or 13.
You control the output. There are a few options you can change:
- Output style: Idiomatic, Explicit, or Compatibility-focused
- Naming: keep names as they are, or convert to snake_case or lowercase
-
Smart Laravel idioms: for example, collapsing
created_atandupdated_atintotimestamps(), and soft deletes intosoftDeletes() - Separate FK phase: puts foreign keys in their own step, which helps with migration order
- Exclude tables: skip tables you don't need
It can generate more than migrations. If you want, it can also create models, factories, and seeders from your INSERT statements.
It gives you a conversion report. You can see how many tables and columns were found, how many were converted, and any warnings. There is also a column mapping table that shows each SQL column next to its Laravel version, so you can check it quickly.
Please review the result
I want to be honest about this: no converter is perfect.
SQL dialects have many database-specific things, like storage engines, collations, generated columns, and special default expressions. Some of these don't map directly to Laravel's Schema Builder.
So treat the output as a strong starting point, not the final answer. Before you use it:
- Compare the migration with your original SQL
- Check data types, defaults, and nullable columns
- Check the order of your migrations, because foreign keys need the referenced table to exist first
- Run it on a test database before anything serious
The tool saves you the repetitive typing. You still do the thinking.
Who is it for?
- Developers moving a legacy PHP project to Laravel
- Anyone given a
.sqlfile and asked to "make it Laravel" - People who want to quickly turn a schema into migrations, models, and factories
- Students learning how SQL types map to Laravel's Blueprint
Try it
You can find the tool here:
👉 SQL to Laravel Migration Converter
If you try it and something doesn't convert correctly, or you have an idea for a feature, please tell me in the comments. Real SQL schemas are messy, and feedback from real projects helps me improve it.
I'm also adding more free developer tools to AabiTech, so take a look if you're interested.
Thanks for reading! 🙌
Top comments (0)