MIT Licensed

Open source, no black boxes.

The SchemaLens diff engine is open source. Inspect the parser, audit the diff algorithm, and self-host if you want. We believe schema diff is infrastructure — and infrastructure should be transparent.

🔍 Why open source the engine?

Database schemas are sensitive. When you paste CREATE TABLE statements into a tool, you need to trust what happens next. Closed-source diff tools ask you to believe their marketing. We think the code should speak for itself.

Our engine is a plain JavaScript module with zero runtime dependencies. It parses SQL into an AST, runs a semantic diff at the table/column/index level, and generates migration scripts. Every step is inspectable.

Zero network requests Zero runtime dependencies 1,500+ lines, fully commented MIT license — use anywhere

⚙️ Architecture

The engine is a single JavaScript file with a clear data flow. No frameworks. No magic.

Parser

Tokenizer → AST

Custom tokenizer splits SQL into statements, then builds an abstract syntax tree for tables, columns, indexes, constraints, views, functions, and triggers.

Diff

Semantic Comparison

Compares schemas object-by-object (not line-by-line). Detects added/removed tables, column type changes, default value drift, index modifications, and renamed objects via Levenshtein heuristic.

Analysis

Risk & Breaking Changes

Calculates a risk score (Low / Medium / High) based on change severity. Flags breaking changes like dropped columns used by views, type narrowing, and NOT NULL additions without defaults.

Generator

Migration SQL

Generates dialect-specific ALTER TABLE scripts for PostgreSQL, MySQL, MariaDB, SQLite, SQL Server, Oracle, and generic ANSI SQL.

📦 Use it in your project

The engine is available as a standalone npm package. Install it in Node.js, a serverless function, or bundle it for the browser.

Install

npm install schemalens-engine

Diff two schemas

const { diffSchemas, generateMigration, detectBreakingChanges } = require('schemalens-engine');

const result = diffSchemas(oldSQL, newSQL, { dialect: 'postgres' });
console.log(result.addedTables);
console.log(result.modifiedTables);

const migration = generateMigration(result, { dialect: 'postgres' });
console.log(migration);

const breaking = detectBreakingChanges(result);
console.log(breaking.length + ' breaking changes found');

Supported dialects

  • PostgreSQL — including custom types, enums, arrays, and extensions
  • MySQL / MariaDB — including spatial indexes and full-text search
  • SQLite — including WITHOUT ROWID and STRICT tables
  • SQL Server / Azure SQL — including clustered columnstore indexes
  • Oracle — including PL/SQL triggers and procedures

🛡️ Trust through transparency

We know developers are skeptical of new tools. Here is how we address the common concerns:

"How do I know my schema data is safe?"

The engine runs entirely in your browser or your own server. When you use schemalens.tech, the web app loads the engine as a local JavaScript file. Your SQL never leaves your machine. You can verify this in the Network tab — zero uploads.

"What if the diff is wrong?"

The diff algorithm is deterministic and fully testable. We ship with 17+ unit tests covering edge cases like composite primary keys, foreign key cascades, and generated columns. You can run the test suite locally with node test-all.js.

"Why not just use Liquibase / Prisma Migrate / schemalex?"

Those are excellent tools for managed migration lifecycles. SchemaLens fills a different niche: instant, zero-setup ad-hoc diffs when you have two DDL dumps and need to see what changed in 10 seconds. Our open-source engine means you can also embed the diff logic into your own CI pipeline without pulling in a heavy framework.

🤝 Contribute

We welcome bug reports, feature requests, and pull requests. The engine is intentionally simple — we want to keep it that way. Before contributing, please read our guidelines:

  • Scope: Schema diff and migration generation only. No query builder, no ER diagrams, no live DB connections in the engine.
  • Tests: Every bug fix must include a test case in test-all.js.
  • Style: Vanilla JS. No TypeScript, no build step, no bundler.
  • Performance: The engine must stay under 50KB minified. Be mindful of algorithmic complexity.

Found a parsing edge case? Open an issue with the minimal SQL that reproduces it. We'll add it to the test suite and fix it.

📜 License

SchemaLens Engine is released under the MIT License.

MIT License

Copyright (c) 2026 SchemaLens

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND...

In plain English: you can use the engine in commercial projects, modify it, redistribute it, and even sell tools built on top of it. We only ask that you include the license notice.

Try the engine now

No install. No account. Paste two schemas and see the diff in 10 seconds.

Open SchemaLens

Or install the CLI and diff schemas from your terminal.